Part Number Hot Search : 
17000 80N06 HYS64 17000 STM32L0 78054 G5110 47M10
Product Description
Full Text Search
 

To Download UPSD3212A-40U6T Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  january 2009 rev 6 1/181 1 upsd3212a upsd3212c, upsd3212cv flash programmable system devices with 8032 mcu and usb and programmable logic features fast 8-bit 8032 mcu ? 40 mhz at 5.0 v, 24 mhz at 3.3 v ? core, 12-clocks per instruction dual flash memories with memory management ? place either memory into 8032 program address space or data address space ? read-while-write operation for in- application programming and eeprom emulation ? single voltage program and erase ? 100 k minimum erase cycles, 15-year retention clock, reset, and supply management ? normal, idle, and power down modes ? power-on and low voltage reset supervisor ? programmable watchdog timer programmable logic, general-purpose ? 16 macrocells ? implements state machines, glue-logic, etc. timers and interrupts ? three 8032 standard 16-bit timers ? 10 interrupt sources with two external interrupt pins a/d converter ? four channels, 8-bit resolution, 10 s communication interfaces ? usb v1.1, low-speed 1.5 mbps, 3 endpoints ?i 2 c master/slave bus controller ? two uarts with independent baud rate ? six i/o ports with up to 46 i/o pins ? 8032 address/data bus available on tqfp80 package ? 5 pwm outputs, 8-bit resolution jtag in-system programming ? program the entire device in as little as 10 seconds single supply voltage ? 4.5 to 5.5 v ? 3.0 to 3.6 v ecopack? packages lqfp52 (t) 52-lead, thin, quad flat package lqfp80 (u) 80-lead, thin, quad flat package table 1. device summary order code max. clock (mhz) 1st flash 2nd flash sram gpio usb 8032 bus v cc (v) pkg. temp. upsd3212c-40t6 40 64 kb 16 kb 2 kb 37 no no 4.5-5.5 tqfp52 ?40c to 85c upsd3212cv-24t6 24 64 kb 16 kb 2 kb 37 no no 3.0-3.6 tqfp52 ?40c to 85c upsd3212c-40u6 40 64 kb 16 kb 2 kb 46 no yes 4.5-5.5 tqfp80 ?40c to 85c upsd3212cv-24u6 24 64 kb 16 kb 2 kb 46 no yes 3.0-3.6 tqfp80 ?40c to 85c upsd3212a-40t6 40 64 kb 16 kb 2 kb 37 yes no 4.5-5.5 tqfp52 ?40c to 85c upsd3212a-40u6 40 64 kb 16 kb 2 kb 46 yes yes 4.5-5.5 tqfp80 ?40c to 85c www.st.com
contents upsd3212a, upsd3212c, upsd3212cv 2/181 contents 1 upsd321xx description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.1 52-pin package i/o port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2 architecture overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.1 memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.2 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.2.1 accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.2.2 b register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.2.3 stack pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.2.4 program counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.2.5 program status word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.2.6 registers r0~r7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.2.7 data pointer register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.3 program memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.4 data memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.5 ram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.6 xram-psd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.7 sfr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.8 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.8.1 direct addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.8.2 indirect addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.8.3 register addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.8.4 register-specific addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.8.5 immediate constants addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.8.6 indexed addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.9 arithmetic instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.10 logical instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.11 data transfers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.11.1 internal ram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.11.2 external ram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.11.3 lookup tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 2.12 boolean instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.13 relative offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
upsd3212a, upsd3212c, upsd3212cv contents 3/181 2.14 jump instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 2.15 machine cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 3 upsd321xx hardware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 4 mcu module description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 4.1 special function registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 5 interrupt system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5.1 external int0 interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5.2 timer 0 and 1 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5.3 timer 2 interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5.4 i 2 c interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5.5 external int1 interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 5.6 usb interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 5.7 usart interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 5.8 interrupt priority structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 5.9 interrupt enable structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 5.10 how interrupts are handled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 6 power-saving mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 6.1 idle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 6.2 power-down mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 6.3 power control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 6.4 idle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 6.5 power-down mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 7 i/o ports (mcu module) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 7.1 port type and description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 8 oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 9 supervisory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 9.1 external reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 9.2 low v dd voltage reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
contents upsd3212a, upsd3212c, upsd3212cv 4/181 9.3 watchdog timer overflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 9.4 usb reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 10 watchdog timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 11 timer/counters (timer 0, time r 1 and timer 2) . . . . . . . . . . . . . . . . . . 58 11.1 timer 0 and timer 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 11.1.1 mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 11.1.2 mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 11.1.3 mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 11.1.4 mode 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 11.2 timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 12 standard serial interface (uart) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 12.1 multiprocessor communications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 12.2 serial port control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 12.2.1 baud rates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 12.2.2 using timer 1 to generate baud rates . . . . . . . . . . . . . . . . . . . . . . . . . . 67 12.2.3 using timer/counter 2 to generate baud rates . . . . . . . . . . . . . . . . . . . 67 12.2.4 more about mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 12.2.5 more about mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 12.2.6 more about modes 2 and 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 13 analog-to-digital convertor (a dc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 13.1 adc interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 14 pulse width modulation (pwm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 14.1 4-channel pwm unit (pwm 0-3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 14.2 programmable period 8-bit pwm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 14.3 pwm 4-channel operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 15 i 2 c interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 15.1 serial status register (sxsta: s1sta, s2sta) . . . . . . . . . . . . . . . . . . . . 85 15.2 data shift register (sxdat: s1dat, s2dat) . . . . . . . . . . . . . . . . . . . . . . . 85 15.3 address register (sxadr: s1adr, s2adr) . . . . . . . . . . . . . . . . . . . . . . 86
upsd3212a, upsd3212c, upsd3212cv contents 5/181 16 usb hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 16.1 usb related registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 16.2 transceiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 16.2.1 usb physical layer characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 16.2.2 low speed driver characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 16.3 receiver characteristic s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 16.4 external usb pull-up resistor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 17 psd module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 17.1 functional overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 17.2 in-system programming (isp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 18 development system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 19 psd module register description and address offset . . . . . . . . . . . . 103 20 psd module detailed operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 21 memory blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 21.1 primary flash memory and secondary flash memory description . . . . 105 21.2 memory block select signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 21.2.1 ready/busy (pc3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 21.2.2 memory operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 21.3 instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 21.4 power-down instruction and power-up mode . . . . . . . . . . . . . . . . . . . . . 107 21.4.1 power-up mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 21.5 read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 21.5.1 read memory contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 21.5.2 read memory sector protection status . . . . . . . . . . . . . . . . . . . . . . . . 108 21.5.3 reading the erase/program status bits . . . . . . . . . . . . . . . . . . . . . . . . 108 21.5.4 data polling flag (dq7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 21.5.5 toggle flag (dq6) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 21.5.6 error flag (dq5) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 21.5.7 erase time-out flag (dq3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 21.6 programming flash memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 21.6.1 data polling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
contents upsd3212a, upsd3212c, upsd3212cv 6/181 21.6.2 data toggle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 21.7 erasing flash memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 21.7.1 flash bulk erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 21.7.2 flash sector erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 21.7.3 suspend sector erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 21.7.4 resume sector erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 21.8 specific features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 21.8.1 flash memory sector protect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 21.8.2 reset flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 21.9 sram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 21.10 sector select and sram select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 21.10.1 example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 21.10.2 memory select configuration in program and data spaces . . . . . . . . . 116 21.10.3 separate space mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 21.10.4 combined space modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 21.11 page register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 22 plds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 22.1 turbo bit in psd module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 22.2 decode pld (dpld) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 22.3 complex pld (cpld) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 22.4 output macrocell (omc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 22.5 product term allocator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 22.5.1 loading and reading the output macrocells (omc) . . . . . . . . . . . . . . 124 22.5.2 omc mask register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 22.5.3 output enable of the omc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 22.6 input macrocells (imc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 23 i/o ports (psd module) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 23.1 general port architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 23.2 port operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 23.3 mcu i/o mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 23.4 pld i/o mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 23.5 address out mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 23.6 peripheral i/o mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
upsd3212a, upsd3212c, upsd3212cv contents 7/181 23.7 jtag in-system programming (isp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 23.8 port configuration registers (pcr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 23.8.1 control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 23.8.2 direction register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 23.8.3 drive select register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 23.9 port data registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 23.9.1 data in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 23.9.2 data out register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 23.9.3 output macrocells (omc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 23.9.4 omc mask register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 23.9.5 input macrocells (imc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 23.9.6 enable out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 23.10 ports a and b ? functionality and structure . . . . . . . . . . . . . . . . . . . . . . 133 23.11 port c ? functionality and structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 23.12 port d ? functionality and structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 23.13 external chip select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 24 power management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 24.1 pld power management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 24.2 psd chip select input (csi, pd2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 24.3 input clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 24.4 input control signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 25 reset timing and device status at reset . . . . . . . . . . . . . . . . . . . . . . 142 25.1 warm reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 25.2 i/o pin, register and pld status at reset . . . . . . . . . . . . . . . . . . . . . . 142 26 programming in-circuit using the jtag se rial interface . . . . . . . . . . 144 26.1 standard jtag signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 26.2 jtag extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 26.3 security and flash memory protection . . . . . . . . . . . . . . . . . . . . . . . . . . 145 27 initial delivery state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 28 ac/dc parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
contents upsd3212a, upsd3212c, upsd3212cv 8/181 29 maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 30 emc characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 30.1 functional ems (electromagnetic susceptibility) . . . . . . . . . . . . . . . . . . 151 30.1.1 esd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 30.1.2 ftb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 30.2 designing hardened software to avoid noise problems . . . . . . . . . . . . . 151 30.2.1 software recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 30.2.2 prequalification trials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 30.3 absolute maximum ratings (electrical sensitivity) . . . . . . . . . . . . . . . . . . 152 30.3.1 electro-static discharge (esd) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 30.3.2 latch-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 30.3.3 dynamic latch-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 31 dc and ac parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 32 package mechanical information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 33 part numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 34 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
upsd3212a, upsd3212c, upsd3212cv upsd321xx description 9/181 1 upsd321xx description the upsd321xx series combines a fast 8051-based microcontroller with a flexible memory structure, programmable logic, and a rich peripheral mix including usb, to form an ideal embedded controller. at its core is an industry-standard 8032 mcu operating up to 40mhz. a jtag serial interface is used for in-system programming (isp) in as little as 10 seconds, perfect for manufacturing and lab development. the usb 1.1 low-speed interface has one control endpoint and two interrupt endpoints suitable for hid class drivers. the 8032 core is coupled to programmable system device (psd) architecture to optimize the 8032 memory structure, offering two independent banks of flash memory that can be placed at virtually any address within 8032 program or data address space, and easily paged beyond 64 kbytes using on-chip programmable decode logic. dual flash memory banks provide a robust solution for remote product updates in the field through in-application programming (iap). dual flash banks also support eeprom emulation, eliminating the ne ed for external eeprom chips. general purpose programmable logic (pld) is included to build an endless variety of glue- logic, saving external logic devices. the pld is configured using the software development tool, psdsoft express, available from the web at www.st.com/psm , at no charge. the upsd321xx also includes supervisor func tions such as a programmable watchdog timer and low-voltage reset. in order to meet environmental requirements, st offers these devices in different grades of ecopack? packages, depending on their level of environmental compliance. ecopack? specifications, grade definitions and product status are available at: www.st.com. ecopack? is an st trademark.
upsd321xx description upsd3212a, upsd3212c, upsd3212cv 10/181 figure 1. upsd321xx block diagram pa0:7 pb0:7 pd1:2 pc0:7 mcu bus p4.0:7 p1.0:7 p3.0:7 upsd321x system bus dedicated pins supervisor: watchdog and low-voltage reset 1st flash memory: 64k bytes 2nd flash memory: 16k bytes sram: 2k bytes programmable decode and page logic general purpose programmable logic, 16 macrocells (8) gpio, port a (80-pin only) (8) gpio, port b (4) gpio, port c (2) gpio, port d jtag isp 8032 address/data/control bus (80-pin device only) v cc , v dd , gnd, reset, crystal in 8032 mcu core (3) 16-bit timer/ counters (2) external interrupts i 2 c (4) 8-bit adc uart0 (8) gpio, port 1 (8) gpio, port 3 (8) gpio, port 4 uart1 (5) 8-bit pwm ai10428b usb+, usb? usb v1.1
upsd3212a, upsd3212c, upsd3212cv upsd321xx description 11/181 1. pull-up resistor required on pin 5 (2 k for 3 v devices, 7.5 k for 5 v devices) for al l 52-pin devices, with or without usb function. figure 2. tqfp52 connections 39 p1.5/adc1 38 p1.4/adc0 37 p1.3/txd1 36 p1.2/rxd1 35 p1.1/t2x 34 p1.0/t2 33 v cc 32 xtal2 31 xtal1 30 p3.7/scl1 29 p3.6/sda1 28 p3.5/t1 27 p3.4/t0 pd1/clkin pc7 jtag tdo jtag tdi usb? (1) pc4/terr_ usb+ v cc gnd pc3/tstat pc2/v stby jtag tck jtag tms 1 2 3 4 5 6 7 8 9 10 11 12 13 52 51 50 49 48 47 46 45 44 43 42 41 40 pb0 pb1 pb2 pb3 pb4 pb5 vref gnd reset_ pb6 pb7 p1.7/adc3 p1.6/adc2 14 15 16 17 18 19 20 21 22 23 24 25 26 p4.7/pwm4 p4.6/pwm3 p4.5/pwm2 p4.4/pwm1 p4.3/pwm0 gnd p4.2 p4.1 p4.0 p3.0/rxd p3.1/txd p3.2/exint0 p3.3/exint1 ai07423c
upsd321xx description upsd3212a, upsd3212c, upsd3212cv 12/181 1. pull-up resistor required on pin 8 (2 k for 3 v devices, 7.5 k for 5 v devices) for al l 82-pin devices, with or without usb function. 2. nc = not connected figure 3. tqfp80 connections table 2. 80-pin package pin description port pin signal name pin no. in/ out function basic alternate ad0 36 i/o external bus: multiplexed address/data bus a1/d1 ad1 37 i/o multiplexed address/data bus a0/d0 ad2 38 i/o multiplexed address/data bus a2/d2 ad3 39 i/o multiplexed address/data bus a3/d3 ad4 41 i/o multiplexed address/data bus a4/d4 ad5 43 i/o multiplexed address/data bus a5/d5 ad6 45 i/o multiplexed address/data bus a6/d6 60 p1.5/adc1 59 p1.4/adc0 58 p1.3/txd1 57 a11 56 p1.2/rxd1 55 a10 54 p1.1/tx2 53 a9 52 p1.0/t2 51 a8 50 v cc 49 xtal2 48 xtal1 47 ad7 46 p3.7/scl1 45 ad6 44 p3.6/sda1 43 ad5 42 p3.5/t1 41 ad4 pd2 p3.3 /exint1 pd1/clkin ale pc7 jtag/tdo jtag/tdi usb? (1) pc4/terr_ usb+ nc (2) v cc gnd pc3/tstat pc2/v stby jtag tck nc (2) p4.7/pwm4 p4.6/pwm3 jtag tms 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 pb0 p3.2/exint0 pb1 p3.1/txd0 pb2 p3.0/rxd0 pb3 pb4 pb5 nc (2) v ref gnd reset_ pb6 pb7 rd_ p1.7/adc3 psen_ wr_ p1.6/adc2 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 pa7 pa6 p4.5/pwm2 pa5 p4.4/pwm1 pa4 p4.3/pwm0 pa3 gnd p4.2 p4.1 pa2 p4.0 pa1 pa0 ad0 ad1 ad2 ad3 p3.4/t0 ai07424c
upsd3212a, upsd3212c, upsd3212cv upsd321xx description 13/181 ad7 47 i/o multiplexed address/data bus a7/d7 p1.0 t2 52 i/o general i/o port pin timer 2 count input p1.1 tx2 54 i/o general i/o port pin timer 2 trigger input p1.2 rxd1 56 i/o general i/o port pin 2nd uart receive p1.3 txd1 58 i/o general i/o port pin 2nd uart transmit p1.4 adc0 59 i/o general i/o port pin adc channel 0 input p1.5 adc1 60 i/o general i/o port pin adc channel 1 input p1.6 adc2 61 i/o general i/o port pin adc channel 2 input p1.7 adc3 64 i/o general i/o port pin adc channel 3 input a8 51 o external bus, address a8 a9 53 o external bus, address a9 a10 55 o external bus, address a10 a11 57 o external bus, address a11 p3.0 rxd0 75 i/o general i/o port pin uart receive p3.1 txd0 77 i/o general i/o port pin uart transmit p3.2 exint0 79 i/o general i/o port pin interrupt 0 input / timer 0 gate control p3.3 exint1 2 i/o general i/o port pin interrupt 1 input / timer 1 gate control p3.4 t0 40 i/o general i/o port pin counter 0 input p3.5 t1 42 i/o general i/o port pin counter 1 input p3.6 sda1 44 i/o general i/o port pin i 2 c bus serial data i/o p3.7 scl1 46 i/o general i/o port pin i 2 c bus clock i/o p4.0 ddc sda 33 i/o general i/o port pin p4.1 ddc scl 31 i/o general i/o port pin p4.2 ddc v sync 30 i/o general i/o port pin p4.3 pwm0 27 i/o general i/o port pin 8-bit pulse width modulation output 0 p4.4 pwm1 25 i/o general i/o port pin 8-bit pulse width modulation output 1 p4.5 pwm2 23 i/o general i/o port pin 8-bit pulse width modulation output 2 p4.6 pwm3 19 i/o general i/o port pin 8-bit pulse width modulation output 3 table 2. 80-pin package pin description (continued) port pin signal name pin no. in/ out function basic alternate
upsd321xx description upsd3212a, upsd3212c, upsd3212cv 14/181 p4.7 pwm4 18 i/o general i/o port pin programmable 8-bit pulse width modulation output 4 usb? 8 i/o pull-up resistor required (2 k for 3v devices, 7.5k for 5 v devices) v ref 70 o reference voltage input for adc rd_ 65 o read signal, external bus wr_ 62 o write signal, external bus psen_ 63 o psen signal, external bus ale 4 o address latch signal, external bus reset_ 68 i active low reset input xtal1 48 i oscillator input pin for system clock xtal2 49 o oscillator outpu t pin for system clock pa0 35 i/o general i/o port pin pld macrocell outputs pld inputs latched address out (a0- a7) peripheral i/o mode pa1 34 i/o general i/o port pin pa2 32 i/o general i/o port pin pa3 28 i/o general i/o port pin pa4 26 i/o general i/o port pin pa5 24 i/o general i/o port pin pa6 22 i/o general i/o port pin pa7 21 i/o general i/o port pin pb0 80 i/o general i/o port pin pld macrocell outputs pld inputs latched address out (a0- a7) pb1 78 i/o general i/o port pin pb2 76 i/o general i/o port pin pb3 74 i/o general i/o port pin pb4 73 i/o general i/o port pin pb5 72 i/o general i/o port pin pb6 67 i/o general i/o port pin pb7 66 i/o general i/o port pin table 2. 80-pin package pin description (continued) port pin signal name pin no. in/ out function basic alternate
upsd3212a, upsd3212c, upsd3212cv upsd321xx description 15/181 1.1 52-pin package i/o port the 52-pin package members of the upsd321xx devices have the same port pins as those of the 80-pin package except: port 0 (p0.0-p0.7, external address/data bus ad0-ad7) port 2 (p2.0-p2.3, external address bus a8-a11) port a (pa0-pa7) port d (pd2) bus control signal (rd,wr,psen,ale) pin 5 requires a pull-up resistor (2 k for 3 v devices, 7.5 k for 5 v devices) for all devices, with or without usb function. jtag tms 20 i jtag pin pld macrocell outputs pld inputs jtag pins are dedicated pins jtag tck 16 i jtag pin pc3 tstat 14 i/o general i/o port pin pc4 terr_ 9 i/o general i/o port pin jtag tdi 7 i jtag pin jtag tdo 6 o jtag pin pc7 5 i/o general i/o port pin pd1 clkin 3 i/o general i/o port pin pld i/o clock input to pld and apd pd2 1 i/o general i/o port pin pld i/o chip select to psd module vcc 12 vcc 50 gnd 13 gnd 29 gnd 69 usb+ 10 nc 11 nc 17 nc 71 table 2. 80-pin package pin description (continued) port pin signal name pin no. in/ out function basic alternate
architecture overview upsd3212a, upsd3212c, upsd3212cv 16/181 2 architecture overview 2.1 memory organization the upsd321xx devices? standard 8032 core ha s separate 64-kbyte address spaces for program memory and data memory. program memory is where the 8032 executes instructions from. data memory is used to hold data variables. flash memory can be mapped in either program or data space. the flash memory consists of two flash memory blocks: the main flash memory (512 kbit) and the secondary flash memory (128 kbit). except during flash memory programming or update, flash memory can only be read, not written to. a page register is used to access memory beyond the 64-kbyte address space. refer to the psd module for details on mapping of the flash memory. the 8032 core has two types of data memory (internal and external) that can be read and written. the internal sram consists of 256 bytes, and includes the stack area. the sfr (special function registers) occupies the upper 128 bytes of the internal sram, the registers can be accessed by direct addressing only. another 2 kbytes resides in the psd module that can be mapped to any address space defined by the user. 2.2 registers the 8032 has several registers; these are the program counter (pc), accumulator (a), b register (b), the stack pointer (sp), the program status word (psw), general purpose registers (r0 to r7), and dptr (data pointer register). figure 4. memory map and address space ai07425 secondary flash flash main 16kb 64kb ff 7f 0 2kb int. ram ext. ram addressing indirect indirect direct or addressing addressing direct sfr internal ram space (256 bytes) external ram space (movx) flash memory space
upsd3212a, upsd3212c, upsd3212cv architecture overview 17/181 figure 5. 8032 mcu registers 2.2.1 accumulator the accumulator is the 8-bit general purpose register, used for data operation such as transfer, temporary saving, and conditional tests. the accumulator can be used as a 16-bit register with b register as shown below. figure 6. configuration of ba 16-bit registers 2.2.2 b register the b register is the 8-bit general purpose register, used for an arithmetic operation such as multiply, division with accumulator. 2.2.3 stack pointer the stack pointer register is 8 bits wide. it is incremented before data is stored during push and call executions. while the stack may reside anywhere in on-chip ram, the stack pointer is initialized to 07h after reset. this causes the stack to begin at location 08h. figure 7. stack pointer ai06636 accumulator b register stack pointer program counter program status word general purpose register (bank0-3) data pointer register pch dptr(dph) a b sp pcl psw r0-r7 dptr(dpl) ai06637 two 8-bit registers can be used as a "ba" 16-bit registers a b a b ai06638 sp (stack pointer) could be in 00h-ffh sp 00h stack area (30h-ffh) 00h-ffh hardware fixed bit 15 bit 0 bit 8 bit 7
architecture overview upsd3212a, upsd3212c, upsd3212cv 18/181 2.2.4 program counter the program counter is a 16-bit wide which consists of two 8-bit registers, pch and pcl. this counter indicates the ad dress of the next instruct ion to be executed. in reset state, the program counter has reset routine address (pch:00h, pcl:00h). 2.2.5 program status word the program status word (psw) contains several bits that reflect the current state of the cpu and select internal ram (00h to 1fh: bank0 to bank3). the psw is described in figure 8 . it contains the carry flag, the auxilia ry carry flag, the half carry (for bcd operation), the general purpose flag, the register bank select flags, the overflow flag, and parity flag. [carry flag, cy]. this flag stores any carry or not borrow from the alu of cpu after an arithmetic operation and is also changed by the shift instruction or rotate instruction. [auxiliary carry flag, ac]. after operation, this fl ag is set when there is a carry from bit 3 of alu or there is no borrow from bit 4 of alu. [register bank select flags, rs0, rs1]. these flags select one of four banks (00~07h:bank0, 08~0fh:bank1, 10~17h:bank2, 17~1fh:bank3) in internal ram. [overflow flag, ov]. this flag is set to '1' w hen an overflow occurs as the result of an arithmetic operation involving signs. an overflow occurs when the result of an addition or subtraction exceeds +127 (7fh) or -128 (80h). the clrv instruction clears the overflow flag. there is no set instruction. when the bit instruction is executed, bit 6 of memory is copied to this flag. [parity flag, p]. this flag reflects the number of accumulator?s 1. if the number of accumulator?s 1 is odd, p=0; otherwise, p=1. the sum when adding accumulator?s 1 to p is always even. 2.2.6 registers r0~r7 general purpose 8-bit registers that are locked in the lower portion of internal data area. 2.2.7 data pointer register data pointer register is 16-bit wide which consis ts of two-8bit registers, dph and dpl. this register is used as a data pointer for the data transmission with external data memory in the psd module. figure 8. psw (program status word) register ai06639 cy reset value 00h parity flag bit not assigned overflow flag register bank select flags (to select bank0-3) carry flag auxillary carry flag general purpose flag ac fo rs1 rs0 ov p msb lsb psw
upsd3212a, upsd3212c, upsd3212cv architecture overview 19/181 2.3 program memory the program memory consists of two flash memories: the main flash memory (64 kbit) and the secondary flash memory (16 kbit). the flash memory can be mapped to any address space as defined by the user in the psdsoft tool. it can also be mapped to data memory space during flash memory update or programming. after reset, the cpu begins execution from location 0000h. as shown in figure 9 , each interrupt is assigned a fixed location in program memory. the interrupt causes the cpu to jump to that location, where it commences execution of the service routine. external interrupt 0, for example, is assigned to location 0003h. if external interrupt 0 is going to be used, its service routine must begin at location 0003h. if the interrupt is not going to be used, its service location is available as general purpose program memory. the interrupt service locations are spaced at 8-byte intervals: 0003h for external interrupt 0, 000bh for timer 0, 0013h for external interrupt 1, 001bh for timer 1 and so forth. if an interrupt service routine is short enough (as is often the case in control applications), it can reside entirely within that 8-byte interval. lo nger service routines can use a jump instruction to skip over subsequent interrupt locations, if other interrupts are in use. 2.4 data memory the internal data memory is divided into four physically separated blocks: 256 bytes of internal ram, 128 bytes of special function registers (sfrs) areas and 2 kbytes (xram- psd) in the psd module. 2.5 ram four register banks, each 8 registers wide, occupy locations 0 through 31 in the lower ram area. only one of these banks may be enabled at a time. the next 16 bytes, locations 32 through 47, contain 128 directly addressable bit locations. the stack depth is only limited by the available internal ram space of 256 bytes. figure 9. interrupt location of program memory ai06640 0000h reset 8 bytes ? ? ? ? ? interrupt location 0003h 000bh 0013h 008bh ? ? ? ?
architecture overview upsd3212a, upsd3212c, upsd3212cv 20/181 2.6 xram-psd the 2 kbytes of xram-psd resides in the psd module and can be mapped to any address space through the dpld (decoding pld) as defined by the user in psdsoft development tool. 2.7 sfr the sfrs can only be addressed directly in the address range from 80h to ffh. ta b l e 1 5 gives an overview of the special function registers. sixteen address in the sfrs space are both-byte and bit-addressable. the bit-addressable sfrs are those whose address ends in 0h and 8h. the bit addresses in this area are 80h to ffh. table 3. ram address byte address (in hexadecimal) byte address (in decimal) ffh 255 30h 48 msb bit address (hex) lsb 2fh 7f 7e 7d 7c 7b 7a 79 78 47 2eh777675747372717046 2dh 6f 6e 6d 6c 6b 6a 69 68 45 2ch676665646362616044 2bh 5f 5e 5d 5c 5b 5a 59 58 43 2ah575655545352515042 29h 4f 4e 4d 4c 4b 4a 49 48 41 28h474645444342414040 27h 3f 3e 3d 3c 3b 3a 39 38 39 26h373635343332313038 25h 2f 2e 2d 2c 2b 2a 29 28 37 24h272625242322212036 23h 1f 1e 1d 1c 1b 1a 19 18 35 22h171615141312111034 21h 0f 0e 0d 0c 0b 0a 09 08 33 20h070605040302010032 1fh register bank 3 31 18h 24 17h register bank 2 23 10h 16 0fh register bank 1 15 08h 8 07h register bank 0 7 00h 0
upsd3212a, upsd3212c, upsd3212cv architecture overview 21/181 2.8 addressing modes the addressing modes in upsd321xx devices instruction set are as follows 1. direct addressing 2. indirect addressing 3. register addressing 4. register-specific addressing 5. immediate constants addressing 6. indexed addressing 2.8.1 direct addressing in a direct addressing the operand is specified by an 8-bit address field in the instruction. only internal data ram and sfrs (8 0~ffh ram) can be directly addressed. example: mov a, 3eh ; a <----- ram[3e] figure 10. direct addressing 2.8.2 indirect addressing in indirect addressing the instruction specifies a register which contains the address of the operand. both internal and external ram can be indirectly addressed. the address register for 8-bit addresses can be r0 or r1 of the selected register bank, or the stack pointer. the address register for 16-bit addresses can only be the 16-bit ?data pointer? register, dptr. example: mov @r1, #40 h ;[r1] <-----40h figure 11. indirect addressing ai06641 3eh program memory 04 a ai06642 r1 55h program memory 55 40h
architecture overview upsd3212a, upsd3212c, upsd3212cv 22/181 2.8.3 register addressing the register banks, containing registers r0 through r7, can be accessed by certain instructions which carry a 3-bit register specification within the opcode of the instruction. instructions that access the registers this way are code efficient, since this mode eliminates an address byte. when the instruction is executed, one of four banks is selected at execution time by the two bank select bits in the psw. example: mov psw, #0001000b ; select bank0 mov a, #30h mov r1, a 2.8.4 register-specific addressing some instructions are specific to a certain re gister. for example, some instructions always operate on the accumulator, or data pointer, etc., so no address byte is needed to point it. the opcode itself does that. 2.8.5 immediate constants addressing the value of a constant can follow the opcode in program memory. example: mov a, #10h. 2.8.6 indexed addressing only program memory can be accessed with indexed addressing, and it can only be read. this addressing mode is intended for reading look-up tables in program memory. a 16-bit base register (either dptr or pc) points to the base of the table, and the accumulator is set up with the table entry number. the address of the table entry in program memory is formed by adding the accumulator data to the base pointer. example: movc a, @a+dptr figure 12. indexed addressing ai06643 3eh program memory acc dptr 3ah 1e73h
upsd3212a, upsd3212c, upsd3212cv architecture overview 23/181 2.9 arithmetic instructions the arithmetic instructions is listed in ta b l e 4 . the table indicates the addressing modes that can be used with each instruction to access the operand. for example, the add a, instruction can be written as: add a, 7fh (direct addressing) add a, @r0 (indirect addressing) add a, r7 (register addressing) add a, #127 (immediate constant) note: any byte in the internal data memory space can be incremented without going through the accumulator. one of the inc instructions operates on the 16-bit data pointer. the data pointer is used to generate 16-bit addresses for external memory, so being able to increment it in one 16-bit operation is a useful feature. the mul ab instruction multiplies the accumulator by the data in the b register and puts the 16-bit product into the concatenated b and accumulator registers. the div ab instruction divides the accumulator by the data in the b register and leaves the 8-bit quotient in the accumulator, and the 8-bit remainder in the b register. in shift operations, dividing a number by 2n shi fts its ?n? bits to the right. using div ab to perform the division completes the shift in 4?s and leaves the b register holding the bits that were shifted out. the daa instruction is for bcd arithmetic operations. in bcd arithmetic, add and addc instructions should always be followed by a daa operation, to ensure that the result is also in bcd. note: daa will not convert a binary number to bcd. the daa operation produces a meaningful result only as the second step in the addition of two bcd bytes. table 4. arithmetic instructions mnemonic operation addressing modes dir. ind. reg. imm. add a, a = a + xxxx addc a,a = a + + c xxxx subb a, a = a ? ? c xxxx inc a = a + 1 accumulator only inc = + 1 x x x inc dptr dptr = dptr + 1 data pointer only dec a = a ? 1 accumulator only dec = ? 1 x x x mul ab b:a = b x a accumulator and b only div ab a = int[ a / b ] b = mod[ a / b ] accumulator and b only da a decimal adjust accumulator only
architecture overview upsd3212a, upsd3212c, upsd3212cv 24/181 2.10 logical instructions ta bl e 5 lists logical instructions for upsd321xx devices. the instructions that perform boolean operations (and, or, exclusive or, not) on bytes perform the operation on a bit- by-bit basis. that is, if the accumulator contains 00110101b and byte contains 01010011b, then: anl a, will leave the accumulato r holding 00010001b. the addressing modes that can be used to access the operand are listed in ta bl e 5 . the anl a, instruction may take any of the forms: anl a,7fh(direct addressing) anl a, @r1 (indirect addressing) anl a,r6 (register addressing) anl a,#53h (immediate constant) note: boolean operations can be performed on any byte in the internal data memory space without going through the accumulator. the xrl , #data instruction, for example, offers a quick and easy way to invert port bits, as in: xrl p1, #0ffh. if the operation is in response to an interrupt, not using the accumulator saves the time and effort to push it onto the stack in the service routine. the rotate instructions (rl a, rlc a, etc.) shift the accumulator 1 bit to the left or right. for a left rotation, the msb rolls into the lsb position. for a right rotation, the lsb rolls into the msb position. the swap a instruction interchanges the high an d low nibbles within the accumulator. this is a useful operation in bcd manipulations. for example, if the accumulator contains a binary number which is known to be less than 100, it can be quickly converted to bcd by the following code: move b,#10 div ab swap a add a,b dividing the number by 10 leaves the tens digit in the low nibble of th e accumulator, and the ones digit in the b register. the swap and add instructions move the tens digit to the high nibble of the accumulator, and the ones digit to the low nibble. table 5. logical instructions mnemonic operation addressing modes dir. ind. reg. imm. anl a, a = a .and. xxxx anl ,a a = .and. a x anl ,#data a = .and. #data x orl a, a = a .or. xxxx
upsd3212a, upsd3212c, upsd3212cv architecture overview 25/181 2.11 data transfers 2.11.1 internal ram ta bl e 6 shows the menu of instructions that are available for moving data around within the internal memory spaces, and the addressing modes that can be used with each one. the mov , instruction allows data to be transferred between any two internal ram or sfr locations without going through the accumulator. remember, the upper 128 bytes of data ram can be accessed only by indirect addressing, and sfr space only by direct addressing. note: in upsd321xx devices, the stack resides in on-chip ram, and grows upwards. the push instruction first increments the stack pointer (sp), then copies the byte into the stack. push and pop use only direct addressing to identify the byte being saved or restored, but the stack itself is accessed by indirect addressing using the sp register. this means the stack can go into the upper 128 bytes of ram, if they are implemented, but not into sfr space. the data transfer instructions include a 16-bit mov that can be used to initialize the data pointer (dptr) for look-up tables in program memory. the xch a, instruction causes the accumulator and ad-dressed byte to exchange data. the xchd a, @ri instruct ion is similar, but only the low nibbles are involved in the exchange. to see how xch and xchd can be used to facilitate data manipulations, consider first the problem of shifting and 8-digit bcd number two digits to the right. ta b l e 8 shows how this can be done using xch instructions. to aid in understanding how the code works, the contents of the registers that are holding the bcd number and the content of the accumulator are shown alongside each instruction to indicate their status after the instruction has been executed. orl ,a a = .or. a x orl ,#data a = .or. #data x xrl a, a = a .xor. xxxx xrl ,a a = .xor. a x xrl ,#data a = .xor. #data x crl a a = 00h accumulator only cpl a a = .not. a accumulator only rl a rotate a left 1 bit accumulator only rlc a rotate a left through carry accumulator only rr a rotate a right 1 bit accumulator only rrc a rotate a right through carry accumulator only swap a swap nibbles in a accumulator only table 5. logical instructions mnemonic operation addressing modes dir. ind. reg. imm.
architecture overview upsd3212a, upsd3212c, upsd3212cv 26/181 after the routine has been executed, the accumulator contains the two digits that were shifted out on the right. doing the routine with direct movs uses 14 code bytes. the same operation with xchs uses only 9 bytes and executes almost twice as fast. to right-shift by an odd number of digits, a one-digit must be executed. ta bl e 9 shows a sample of code that will right-shift a bcd num ber one digit, using the xchd instru ction. again, t he contents of the registers holding the number and of the accumulator are shown alongside each instruction. first, pointers r1 and r0 are set up to point to the two bytes containing the last four bcd digits. then a loop is executed which leaves the last byte, location 2eh, holding the last two digits of the shifted number. the pointers are decremented, and the loop is repeated for location 2dh. the cjne instruct ion (compare and jump if not equal) is a loop control that will be described later. the loop executed from loop to cjne for r1 = 2eh, 2dh, 2ch, and 2bh. at that point the digit that was originally shifted out on the right has propagated to location 2ah. since that location should be left with 0s, the lost digit is moved to the accumulator. table 7. shifting a bcd number 2 digits to the right (using direct movs: 14 bytes) table 6. data transfer instructions that access internal data memory space mnemonic operation addressing modes dir. ind. reg. imm. mov a, a = xxxx mov ,a = a x x x mov , = xxxx mov dptr,#data16 dptr = 16-bit immediate constant x push inc sp; mov ?@sp?, x pop mov ,?@sp?; dec sp x xch a, exchange contents of a and xxx xchd a,@ri exchange low nibbles of a and @ri x 2a 2b 2c 2d 2e acc mov a,2eh 00 12 34 56 78 78 mov 2eh,2dh 00 12 34 56 56 78 mov 2dh,2ch 00 12 34 34 56 78 mov 2ch,2bh 00 12 12 34 56 78 mov2bh,#0 0000123456 78
upsd3212a, upsd3212c, upsd3212cv architecture overview 27/181 table 8. shifting a bcd number 2 digits to the right (using direct xchs: 9 bytes) table 9. shifting a bcd number one digit to the right 2.11.2 external ram ta bl e 1 0 shows a list of the data transfer instructions that access external data memory. only indirect addressing can be used. the choice is whether to use a one-byte address, @ri, where ri can be either r0 or r1 of the selected register bank, or a two-byte address, @dtpr. note: in all external data ram accesses, the accumulator is always either the destination or source of the data. 2a 2b 2c 2d 2e acc clr a 00 12 34 56 78 00 xch a,2bh 00 00 34 56 78 12 xch a,2ch 00 00 12 56 78 34 xch a,2dh 00 00 12 34 78 56 xch a,2eh 00 00 12 34 56 78 2a 2b 2c 2d 2e acc mov r1,#2eh 00 12 34 56 78 xx mov r0,#2dh 00 12 34 56 78 xx ; loop for r1 = 2eh loop:mov a,@r1 0012345678 78 xchda,@r0 0012345878 76 swap a 00 12 34 58 78 67 mov @r1,a 00 12 34 58 67 67 dec r1 0012345867 67 dec r0 0012345867 67 cnje r1,#2ah,loop 00 12 34 58 67 67 ; loop for r1 = 2dh 0012384567 45 ; loop for r1 = 2ch 0018234567 23 ; loop for r1 = 2bh 0801234567 01 clr a 08 01 23 45 67 00 xch a,2ah 00 01 23 45 67 08
architecture overview upsd3212a, upsd3212c, upsd3212cv 28/181 2.11.3 lookup tables ta bl e 1 1 shows the two instructions that are available for reading lookup tables in program memory. since these instructions access only program memory, the lookup tables can only be read, not updated. the mnemonic is movc for ?move constant.? the first movc instruction in ta bl e 1 1 can accommodate a table of up to 256 entries numbered 0 through 255. the number of the desired entry is loaded into the accumulator, and the data pointer is set up to point to the beginning of the table. then: movc a, @a+dptr copies the desired table entry into the accumulator. the other movc instruction works the same way, except the program counter (pc) is used as the table base, and the table is accessed through a subroutine. first the number of the desired en-try is loaded into the accumulator, and the subroutine is called: mov a , entry number call table the subroutine ?table? would look like this: table: movc a , @a+pc ret the table itself immediately follows the ret (r eturn) instruction is program memory. this type of table can have up to 255 entries, numbered 1 through 255. number 0 cannot be used, because at the time the movc instruction is executed, the pc contains the address of the ret instruction. an entry numbered 0 would be the ret opcode itself. table 10. data transfer instruction that access external data memory space table 11. lookup table read instruction address width mnemonic operation 8 bits movx a,@ri read external ram @ri 8 bits movx @ri,a write external ram @ri 16 bits movx a,@dptr read external ram @dptr 16 bits movx @dptr,a write external ram @dptr mnemonic operation movc a,@a+dptr read program memory at (a+dptr) movc a,@a+pc read program memory at (a+pc)
upsd3212a, upsd3212c, upsd3212cv architecture overview 29/181 2.12 boolean instructions the upsd321xx devices contain a complete boolean (single-bit) processor. one page of the internal ram contains 128 address-able bits, and the sfr space can support up to 128 addressable bits as well. all of the port lines are bit-addressable, and each one can be treated as a separate single-bit port. the instructions that access these bits are not just conditional branches, but a complete menu of move, set, clear, complement, or and and instructions. these kinds of bit operations are not easily obtained in other architectures with any amount of byte-oriented software. the instruction set for the boolean processor is shown in ta b l e 1 2 . all bits accesses are by direct addressing. bit addresses 00h through 7fh are in the lower 128, and bit addresses 80h through ffh are in sfr space. note how easily an internal flag can be moved to a port pin: mov c,flag mov p1.0,c in this example, flag is the name of any addressable bit in the lower 128 or sfr space. an i/o line (the lsb of port 1, in this case) is set or cleared depending on whether the flag bit is '1' or '0.' the carry bit in the psw is used as the single- bit accumulator of the boolean processor. bit instructions that refer to the carry bit as c a ssemble as carry-specific instructions (clr c, etc.). the carry bit also has a direct address, since it resides in the psw register, which is bit-addressable. note: the boolean instruction set includes anl and orl operations, but not the xrl (exclusive or) operation. an xrl operation is simple to implement in software. suppose, for example, it is required to form the exclusive or of two bits: c = bit 1 .xrl. bit2 the software to do that could be as follows: mov c , bit1 jnb bit2, over cpl c over: (continue) first, bit 1 is moved to the carry. if bit2 = 0, then c now contains the correct result. that is, bit 1 .xrl. bit2 = bit1 if bit2 = 0. on the other hand, if bit2 = 1, c now contains the complement of the correct result. it need only be inverted (cpl c) to complete the operation. this code uses the jnb instruction, one of a series of bit-test instructions which execute a jump if the addressed bit is set (jc, jb, jbc) or if the addressed bit is not set (jnc, jnb). in the above case, bit 2 is being tested, and if bit2 = 0, the cpl c instruction is jumped over. jbc executes the jump if the addressed bit is se t, and also clears the bit. thus a flag can be tested and cleared in one operation. all the psw bits are directly addressable, so the parity bit, or the general-purpose flags, for example, are also available to the bit-test instructions.
architecture overview upsd3212a, upsd3212c, upsd3212cv 30/181 2.13 relative offset the destination address for these jumps is specified to the assembler by a label or by an actual address in program memory. however, the destination address assembles to a relative offset byte. this is a signed (two?s complement) offset byte which is added to the pc in two?s complement arithmetic if the jump is executed. the range of the jump is therefore -128 to +127 program memory bytes relative to the first byte following the instruction. 2.14 jump instructions ta bl e 1 3 shows the list of unconditional jump instru ctions. the table lists a single ?jmp add? instruction, but in fact there are three sjmp, ljmp, and ajmp, which differ in the format of the destination address. jmp is a generic mnemonic which can be used if the programmer does not care which way the jump is en-coded. the sjmp instruction encodes the destination add ress as a relative offset, as described above. the instruction is 2 bytes long, consisting of the opcode and the relative offset byte. the jump distance is limited to a range of -128 to +127 bytes relative to the instruction following the sjmp. table 12. boolean instructions mnemonic operation anl c,bit c = a .and. bit anl c,/bit c = c .and. .not. bit orl c,bit c = a .or. bit orl c,/bit c = c .or. .not. bit mov c,bit c = bit mov bit,c bit = c clr c c = 0 clr bit bit = 0 setb c c = 1 setb bit bit = 1 cpl c c = .not. c cpl bit bit = .not. bit jc rel jump if c =1 jnc rel jump if c = 0 jb bit,rel jump if bit =1 jnb bit,rel jump if bit = 0 jbc bit,rel jump if bit = 1; clr bit
upsd3212a, upsd3212c, upsd3212cv architecture overview 31/181 the ljmp instruction encodes the destination address as a 16-bit constant. the instruction is 3 bytes long, consisting of the opcode and two address bytes. the destination address can be anywhere in the 64k program memory space. the ajmp instruction encodes the destination address as an 11-bit constant. the instruction is 2 bytes long, consisting of the opcode, which itself contains 3 of the 11 address bits, followed by another byte containing the low 8 bits of the destination address. when the instruction is executed, these 11 bits are simply substituted for the low 11 bits in the pc. the high 5 bits stay the same. hence the destination has to be within the same 2k block as the instruction following the ajmp. in all cases the programmer specifies the destination address to the assembler in the same way: as a label or as a 16-b it constant. the assembler will pu t the destinati on address into the correct format for the given instruction. if the format required by the instruction will not support the distance to the specified destination address, a ?destination out of range? message is written into the list file. the jmp @a+dptr instruction supports case jumps. the destination address is computed at execution time as the sum of the 16-bit dp tr register and the accumulator. typically. dptr is set up with the address of a jump table. in a 5-way branch, for ex-ample, an integer 0 through 4 is loaded into the accumulator. the code to be executed might be as follows: mov dptr,#jump table mov a,index_number rl a jmp @a+dptr the rl a instruction converts the index number (0 through 4) to an even number on the range 0 through 8, because each entry in the jump table is 2 bytes long: jump table: ajmp case 0 ajmp case 1 ajmp case 2 ajmp case 3 ajmp case 4 ta bl e 1 3 shows a single ?call addr? instruction, but there are two of them, lcall and acall, which differ in the format in which the subroutine address is given to the cpu. call is a generic mnemonic which can be used if the programmer does not care which way the address is encoded. the lcall instruction uses the 16-bit address format, and the subroutine can be anywhere in the 64k program memory space. the acall instruction uses the 11-bit format, and the subroutine must be in the same 2k block as the instruction following the acall. in any case, the programmer specifies the subroutine address to the assembler in the same way: as a label or as a 16-b it constant. the assembler will pu t the address in to the correct format for the given instructions. subroutines should end with a ret instruction, which returns execution to the instruction following the call. reti is used to return from an interrupt service routine. the only difference between ret and reti is that reti tells the interrupt control system that the interrupt in progress is done.
architecture overview upsd3212a, upsd3212c, upsd3212cv 32/181 if there is no interrupt in progress at the time reti is executed, then the reti is functionally identical to ret. ta bl e 1 4 shows the list of conditiona l jumps available to the upsd321xx device user. all of these jumps specify the destination address by the relative offset method, and so are limited to a jump distance of -128 to +127 bytes from the instruction following the conditional jump instruction. important to note, however, the user specifies to the assembler the actual destination address the same way as the other jumps: as a label or a 16-bit constant. there is no zero bit in the psw. the jz and jnz instructions test the accumulator data for that condition. the djnz instruction (decrement and jump if not zero) is for loop control. to execute a loop n times, load a counter byte with n and terminate the loop with a djnz to the beginning of the loop, as shown below for n = 10: mov counter,#10 loop: (begin loop) ? ? ? (end loop) djnz counter, loop (continue) the cjne instruction (compare and jump if not equal) can also be used for loop control as in ta b l e 9 . two bytes are specified in the operand field of the instruction. the jump is executed only if the two bytes are not equal. in the example of ta bl e 9 shifting a bcd number one digits to the right, the two bytes were data in r1 and the constant 2ah. the initial data in r1 was 2eh. every time the loop was executed, r1 was decremented, and the looping was to continue until the r1 data reached 2ah. another application of this instruction is in ?greater than, less than? comparisons. the two bytes in the operand field are taken as unsigned integers. if the first is less than the second, then the carry bit is set (1). if the first is greater than or equal to the second, then the carry bit is cleared. table 13. unconditional jump instructions mnemonic operation jmp addr jump to addr jmp @a+dptr jump to a+dptr call addr call subroutine at addr ret return from subroutine reti return from interrupt nop no operation
upsd3212a, upsd3212c, upsd3212cv architecture overview 33/181 2.15 machine cycles a machine cycle consists of a sequence of six states, numbered s1 through s6. each state time lasts for two oscillator periods. thus, a ma chine cycle takes 12 os cillator periods or 1s if the oscillator frequency is 12mhz. refer to table 13: state sequence in upsd321xx devices . each state is divided into a phase 1 half an d a phase 2 half. state sequence in upsd321xx devices shows that retrieve/execute sequences in states and phases for various kinds of instructions. normally two program retrievals are generated during each machine cycle, even if the instruction being executed does not require it. if the instruction being executed does not need more code bytes, the cpu simply ignores the extra retrieval, and the program counter is not incremented. execution of a one-cycle instruction ( figure 13: state sequence in upsd321xx devices ) begins during state 1 of the machine cycle, when the opcode is latched into the instruction register. a second retrieve occurs during s4 of the same machine cycle. execution is complete at the end of state 6 of this machine cycle. the movx instructions take two machine cycl es to execute. no program retrieval is generated during the second cycle of a movx instruction. this is the only time program retrievals are skipped. the retrieve/execute sequence for movx instruction is shown in figure 13 (d). table 14. conditional jump instructions mnemonic operation addressing modes dir. ind. reg. imm. jz rel jump if a = 0 accumulator only jnz rel jump if a 0 accumulator only djnz ,rel decrement and jump if not zero x x cjne a,,rel jump if a x x cjne ,#data,rel jump if #data x x
architecture overview upsd3212a, upsd3212c, upsd3212cv 34/181 figure 13. state sequence in upsd321xx devices osc. (xtal2) read opcode read next opcode read next opcode and discard read next opcode and discard read 2nd byte no fetch no fetch no ale s1 s2 s3 s4 s5 s6 s1 s2 s3 s4 s5 s6 s1 s2 s3 s4 s5 s6 read opcode read next opcode s1 s2 s3 s4 s5 s6 read opcode read next opcode s1 s2 s3 s4 s5 s6 read next opcode and discard s1 s2 s3 s4 s5 s6 read next opcode and discard read next opcode and discard read opcode (movx) read next opcode s1 s2 s3 s4 s5 s6 s1 s2 s3 s4 s5 s6 addr data access external memory ai06822 p1 p1 p1 p1 p1 p1 p1 p1 p1 p1 p1 p1 p2 p2 p2 p2 p2 p2 p2 p2 p2 p2 p2 p2 a. 1-byte, 1-cycle instruction, e.g. inc a b. 2-byte, 1-cycle instruction, e.g. add a, adrs c. 1-byte, 2-cycle instruction, e.g. inc dptr d. 1-byte, 2-cycle movx instruction
upsd3212a, upsd3212c, upsd3212cv upsd321xx hardware description 35/181 3 upsd321xx hardware description the upsd321xx devices have a modular architecture with two main functional modules: the mcu module and the psd module. the mcu module consists of a standard 8032 core, peripherals and other system supporting functions. the psd module provides configurable program and data memories to the 8032 cpu core. in addition, it has its own set of i/o ports and a pld with 16 macrocells for general logic implementation. ports a,b,c, and d are general purpose programmable i/o ports that have a port architecture which is different from ports 0-4 in the mcu module. the psd module communicates with the cpu core through the internal address, data bus (a0-a15, d0-d7) and control signals (r d_, wr_, psen_ , ale, reset_). the user defines the decoding pld in the psdsoft development tool and can map the resources in the psd module to any program or data address space. figure 14. upsd321xx functional modules ai07426b 4 channel adc 512kb main flash decode pld 16kb sram cpld - 16 macrocells jtag isp port 1 port 3 2 uarts interrupt 3 timer / counters 256 byte sram 8032 core port 3, uart, intr, timers,i 2 c psd internal bus 8032 internal bus port 1, timers and 2nd uart and adc pwm 5 channels port 4 pwm port a & b, pld i/o and gpio port d gpio port c, jtag, pld i/o and gpio vcc, gnd, xtal 128kb secondary flash dedicated pins i2c port 0, 2 ext. bus reset logic lvd & wdt bus interface reset d0-d7 a0-a15 rd,psen wr,ale page register psd module mcu module usb & transceiver dedicated usb pins
mcu module description upsd3212a, upsd3212c, upsd3212cv 36/181 4 mcu module description this section provides a detail description of the mcu module system functions and peripherals, including: special function registers timers/counter interrupts pwm supervisory function (lvd and watchdog) usart power-saving modes i 2 c bus on-chip oscillator adc i/o ports 4.1 special function registers a map of the on-chip memory area called the special function register (sfr) space is shown in ta b l e 1 5 . note: in the sfrs not all of the addresses are occupied. unoccupied addresses are not implemented on the chip. read accesses to these addresses will in general return random data, and write accesses will have no effect. user software should write '0s' to these unimplemented locations. table 15. sfr memory map f8 ff f0 b (1) f7 e8 uista (1) uien ucon0 ucon1 ucon2 usta uadr udr0 ef e0 acc (1) uscl udt1 udt0 e7 d8 s2con s2sta s2dat s2adr df d0 psw (1) d7 c8 t2con (1) t2mod rcap2l rcap2h tl2 th2 cf c0 p4 (1) c7 b8 ip (1) bf b0 p3 (1) pscl0l pscl0h pscl1l pscl1h ipa b7 a8 ie (1) pwm4p pwm4w wdkey af a0 p2 (1) pwmcon pwm0 pwm1 pwm2 pwm3 wdrst iea a7 98 scon sbuf scon2 sbuf2 9f 90 p1 (1) p1sfs p3sfs p4sfs ascl adat acon 97
upsd3212a, upsd3212c, upsd3 212cv mcu module description 37/181 1. register can be bit addressing 88 tcon (1) tmod tl0 tl1 th0 th1 8f 80 p0 (1) sp dpl dph pcon 87 table 15. sfr memory map (continued) table 16. list of all sfrs sfr addr reg name bit register name reset value comments 76543210 80 p0 ff port 0 81 sp 07 stack ptr 82 dpl 00 data ptr low 83 dph 00 data ptr high 87 pcon smod smod1 lvren adsfint rclk1 tclk1 pd idle 00 power ctrl 88 tcon tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 00 timer / cntr control 89 tmod gate c/t m1 m0 gate c/t m1 m0 00 timer / cntr mode control 8a tl0 00 timer 0 low 8b tl1 00 timer 1 low 8c th0 00 timer 0 high 8d th1 00 timer 1 high 90 p1 ff port 1 91 p1sfs p1s7 p1s6 p1s5 p1s4 00 port 1 select register 93 p3sfs p3s7 p3s6 00 port 3 select register 94 p4sfs p4s7 p4s6 p4s5 p4s4 p4s3 p4s2 p4s1 p4s0 00 port 4 select register 95 ascl 00 8-bit prescaler for adc clock 9 6 a dat a dat 7 a dat 6 a dat 5 a dat 4 a dat 3 a dat 2 a dat 1 a dat 0 0 0 adc data register 97 acon aden ads1 ads0 adst adsf 00 adc control register 98 scon sm0 sm1 sm2 ren tb8 rb8 ti ri 00 serial control register 99 sbuf 00 serial buffer 9a scon2 sm0 sm1 sm2 ren tb8 rb8 ti ri 00 2nd uart ctrl register 9b sbuf2 00 2nd uart serial buffer a0 p2 ff port 2
mcu module description upsd3212a, upsd3212c, upsd3212cv 38/181 a1 pwmcon pwml pwmp pwme cfg4 cfg3 cfg2 cfg1 cfg0 00 pwm control polarity a2 pwm0 00 pwm0 output duty cycle a3 pwm1 00 pwm1 output duty cycle a4 pwm2 00 pwm2 output duty cycle a5 pwm3 00 pwm3 output duty cycle a6 wdrst 00 watch dog reset a7 iea es2 ei 2 c00 interrupt enable (2nd) a8 ie ea - et2 es et1 ex1 et0 ex0 00 interrupt enable a9 aa pwm4p 00 pwm 4 period ab pwm4w 00 pwm 4 pulse width ae wdkey 00 watch dog key register b0 p3 ff port 3 b1 pscl0l 00 prescaler 0 low (8-bit) b2 pscl0h 00 prescaler 0 high (8-bit) b3 pscl1l 00 prescaler 1 low (8-bit) b4 pscl1h 00 prescaler 1 high (8-bit) b7 ipa ps2 pi2c 00 interrupt priority (2nd) b8 ip pt2 ps pt1 px1 pt0 px0 00 interrupt priority c0 p4 ff new port 4 c8 t2con tf2 exf2 rclk tclk exen2 tr2 c/t2 cp/rl2 00 timer 2 control table 16. list of all sfrs (continued) sfr addr reg name bit register name reset value comments 76543210
upsd3212a, upsd3212c, upsd3 212cv mcu module description 39/181 c9 t2mod dcen 00 timer 2 mode ca rcap2l 00 timer 2 reload low cb rcap2h 00 timer 2 reload high cc tl2 00 timer 2 low byte cd th2 00 timer 2 high byte d0 psw cy ac fo rs1 rs0 ov p 00 program status word d2 s2setup 00 i 2 c (s2) setup dc s2con cr2 en1 sta sto addr aa cr1 cr0 00 i 2 c bus control reg dd s2sta gc stop intr tx-md bbusy blost ack_r slv 00 i 2 c bus status de s2dat 00 data hold register df s2adr 00 i 2 c address e0 acc 00 accumulator e1 uscl 00 8-bit prescaler for usb logic e6 udt1 udt1.7 udt1.6 udt1.5 udt1.4 udt1.3 udt1.2 udt1.1 udt1.0 00 usb endpt1 data xmit e7 udt0 udt0.7 udt0.6 udt0.5 udt0.4 udt0.3 udt0.2 udt0.1 udt0.0 00 usb endpt0 data xmit e8 uista suspnd ? rstf txd0f rxd0f rxd1f eopf resumf 00 usb interrupt status e9 uien 00 usb interrupt enable ea ucon0 tseq0 stall0 tx0e rx0e tp0siz3 tp0siz2 tp0siz1 tp0siz0 00 usb endpt0 xmit control eb ucon1 tseq1 ep12sel ? fresum tp1siz3 tp1siz2 tp1siz1 tp1siz0 00 usb endpt1 xmit control ec ucon2 ? ? ? sout ep2e ep1e stall2 stall1 00 usb control register ed usta rseq setup in out rp0siz3 rp0siz2 rp0siz1 rp0siz0 00 usb endpt0 status ee uadr usben uadd6 uadd5 uadd4 uadd3 uadd2 uadd1 uadd0 00 usb address register table 16. list of all sfrs (continued) sfr addr reg name bit register name reset value comments 76543210
mcu module description upsd3212a, upsd3212c, upsd3212cv 40/181 ef udr0 udr0.7 udr0.6 udr0.5 udr0.4 udr0.3 udr0.2 udr0.1 udr0.0 00 usb endpt0 data recv f0 b 00 b register table 16. list of all sfrs (continued) sfr addr reg name bit register name reset value comments 76543210 table 17. psd module register address offset csiop addr offset register name bit register name reset value comments 76543210 00 data in (port a) reads port pins as input 02 control (port a) configure pin between i/o or address out mode. bit = 0 selects i/o 00 04 data out (port a) latched data for output to port pins, i/o output mode 00 06 direction (port a) configures port pin as input or output. bit = 0 selects input 00 08 drive (port a) configures port pin between cmos, open drain or slew rate. bit = 0 selects cmos 00 0a input macrocell (port a) reads latched value on input macrocells 0c enable out (port a) reads the status of the output enable control to the port pin driver. bit = 0 indicates pin is in input mode. 01 data in (port b) 03 control (port b) 00 05 data out (port b) 00 07 direction (port b) 00 09 drive (port b) 00 0b input macrocell (port b) 0d enable out (port b) 10 data in (port c) 12 data out (port c) 00 14 direction (port c) 00 16 drive (port c) 00 18 input macrocell (port c)
upsd3212a, upsd3212c, upsd3 212cv mcu module description 41/181 1. (register address = csiop address + address offset; where csiop address is defined by user in psdsoft) * indicates bit is not used and must be set to ?0?. 1a enable out (port c) 11 data in (port d) * * * * * * only bit 1 and 2 are used 13 data out (port d) ***** * 00 only bit 1 and 2 are used 15 direction (port d) ***** * 00 only bit 1 and 2 are used 17 drive (port d) * * * * * * 00 only bit 1 and 2 are used 1b enable out (port d) ***** * only bit 1 and 2 are used 20 output macrocells ab 21 output macrocells bc 22 mask macrocells ab 23 mask macrocells bc c0 primary flash protection sec3_ prot sec2_ prot sec1_ prot sec0_ prot bit = 1 sector is protected c2 secondary flash protection security _bit ***** sec1_ prot sec0_ prot security bit = 1 device is secured b0 pmmr0 * * pld mcells clk pld array- clk pld tu r b o * apd enable *00 control pld power consumption b4 pmmr2 * pld array ale pld array cntl2 pld array cntl1 pld array cntl0 **00 blocking inputs to pld array e0 page 00 page register e2 vm periph- mode ** fl_ data boot_ data fl_ code boot_ code sr_ code configure 8032 program and data space table 17. psd module register address offset (continued) csiop addr offset register name bit register name reset value comments 76543210
interrupt system upsd3212a, upsd3212c, upsd3212cv 42/181 5 interrupt system there are interrupt requests from 10 sources as follows. int0 external interrupt 2nd usart interrupt timer 0 interrupt i 2 c interrupt int1 external interrupt (or adc interrupt) timer 1 interrupt usb interrupt usart interrupt timer 2 interrupt 5.1 external int0 interrupt the int0 can be either level-active or transition-active depending on bit it0 in register tcon. the flag that actually generates this interrupt is bit ie0 in tcon. when an external interrupt is generated, th e corresponding request flag is cleared by the hardware when the service routine is vectored to only if the interrupt was transition activated. if the interrupt was level activated then the interrupt request flag remains set until the requested interrupt is actually generated. then it has to deactivate the request before the interrupt service routine is completed, or else anot her interrupt will be generated. 5.2 timer 0 and 1 interrupts timer 0 and timer 1 interrupts are generated by tf0 and tf1 which are set by an overflow of their respective timer/counte r registers (except for timer 0 in mode 3). these flags are cleared by the internal hardware when the interrupt is serviced. 5.3 timer 2 interrupt timer 2 interrupt is generated by tf2 which is set by an overflow of timer 2. this flag has to be cleared by the software - not by hardware. it is also generated by the t2ex signal (timer 2 external interrupt p1.1) which is controlled by exen2 and exf2 bits in the t2con register. 5.4 i 2 c interrupt the interrupt of the i 2 c is generated by bit intr in the register s2sta. this flag is cleared by hardware.
upsd3212a, upsd3212c, upsd3212cv interrupt system 43/181 5.5 external int1 interrupt the int1 can be either level active or transition active depending on bit it1 in register tcon. the flag that actually generates this interrupt is bit ie1 in tcon. when an external interrupt is generated, th e corresponding request flag is cleared by the hardware when the service routine is vectored to only if the interrupt was transition activated. if the interrupt was level activated then the interrupt request flag remains set until the requested interrupt is actually generated. then it has to deactivate the request before the interrupt service routine is completed, or else anot her interrupt will be generated. the adc can take over the external int1 to generate an interrupt on conversion being completed 5.6 usb interrupt the usb interrupt is generated when endpoint0 has transmitted a packet or received a packet, when endpoint1 or endpoint2 has transmitted a packet, when the suspend or resume state is detected and every eop received. when the usb interrupt is generated, the corresponding request flag must be cleared by software. the interrupt se rvice routine will have to check the various usb registers to determine the source and clear the corresponding flag. please see the dedicated interrupt control registers for the usb peripheral for more information. 5.7 usart interrupt the usart interrupt is generated by ri (receive interrupt) or ti (transmit interrupt). when the usart interrupt is generated, the corresponding request flag must be cleared by software. the interrupt service routine will have to check the various usart registers to determine the source and clear the corresponding flag. both usart?s are identical, except for the additional interrupt controls in the bit 4 of the additional interrupt control registers (a7h, b7h)
interrupt system upsd3212a, upsd3212c, upsd3212cv 44/181 5.8 interrupt priority structure each interrupt source can be assigned one of two priority levels. interrupt priority levels are defined by the interrupt priority special function register ip and ipa. 0 = low priority 1 = high priority figure 15. interrupt system ai07427b int0 usart timer 0 i2c int1 timer 1 2nd usart timer 2 high low interrupt polling interrupt sources ie / ip / ipa priority global enable usb table 18. sfr register description sfr add r reg name bit register name rese t valu e comments 76543210 a7 iea ? ? ? es2 ? ? ei 2 ceusb00 interrupt enable (2nd) a8 ie ea ? et2 es et1 ex1 et0 ex0 00 interrupt enable b7 ipa ? ? ? ps2 ? ? pi 2 cpusb00 interrupt priority (2nd) b8 ip ? ? pt2 ps pt1 px1 pt0 px0 00 interrupt priority
upsd3212a, upsd3212c, upsd3212cv interrupt system 45/181 a low priority interrupt may be interrupted by a high priority interrupt level interrupt. a high priority interrupt routine cannot be interrupted by any other interrupt source. if two interrupts of different priority occur simultaneously, the high priority level request is serviced. if requests of the same priority are received simultaneously, an in ternal polling sequence determines which request is serviced. thus, within each priority level, there is a second priority structure determined by the polling sequence. 5.9 interrupt enable structure each interrupt source can be individually enabled or disabled by setting or clearing a bit in the interrupt enable special function registers ie and iea. all interrupt sources can also be globally disabled by clearing bit ea in register ie. table 19. priority levels source priority with level int0 0 (highest) 2nd usart 1 timer 0 2 i2c 3 int1 4 reserved 5 timer 1 6 usb 7 1st usart 8 timer 2+exf2 9 (lowest) table 20. description of the ie bits bit symbol function 7ea disable all interrupts: 0: no interrupt with be acknowledged 1: each interrupt source is individually enabled or disabled by setting or clearing its enable bit 6?reserved 5 et2 enable timer 2 interrupt 4 es enable usart interrupt 3 et1 enable timer 1 interrupt 2 ex1 enable external interrupt (int1) 1 et0 enable timer 0 interrupt 0 ex0 enable external interrupt (int0)
interrupt system upsd3212a, upsd3212c, upsd3212cv 46/181 table 21. description of the iea bits bit symbol function 7 ? not used 6 ? not used 5 ? not used 4 es2 enable 2nd usart interrupt 3 ? not used 2 ? not used 1 ei2c enable i2c interrupt 0 eusb enable usb interrupt table 22. description of the ip bits bit symbol function 7?reserved 6?reserved 5 pt2 timer 2 interrupt priority level 4 ps usart interrupt priority level 3 pt1 timer 1 interrupt priority level 2 px1 external interrupt (int1) priority level 1 pt0 timer 0 interrupt priority level 0 px0 external interrupt (int0) priority level table 23. description of the ipa bits bit symbol function 7 ? not used 6 ? not used 5 ? not used 4 ps2 2nd usart interrupt priority level 3 ? not used 2 ? not used 1 pi2c i2c interrupt priority level 0 pusb usb interrupt priority level
upsd3212a, upsd3212c, upsd3212cv interrupt system 47/181 5.10 how interrupts are handled the interrupt flags are sampled at s5p2 of every machine cycle. the samples are polled during following machine cycle. if one of the flags was in a set condition at s5p2 of the preceding cycle, the polling cycle will find it and the interrupt system will generate an lcall to the appropriate service routine, provided this h/w generated lcall is not blocked by any of the following conditions: an interrupt of equal priority or higher priority level is already in progress. the current machine cycle is not the final cycle in the execution of the instruction in progress. the instruction in progress is reti or any access to the interrupt priority or interrupt enable registers. the polling cycle is repe ated with each machi ne cycle, and the values polled are the values that were present at s5p2 of the previous machine cycle. note: if an interrupt flag is active but being responded to for one of the above mentioned conditions, if the flag is still inactive when th e blocking condition is removed, the denied interrupt will not be servic ed. in other words, the fact that the interrupt flag was once active but not serviced is not remem bered. every polling cycle is new. the processor acknowledges an interrupt request by executing a hardware generated lcall to the appropriate service routine. the hardware generated lcall pushes the contents of the program counter on to the stack (but it does not save the psw) and reloads the pc with an address that depends on the source of the interrupt being vectored to as shown in ta b l e 2 4 . execution proceeds from that location until the reti instruction is encountered. the reti instruction informs the processor that the interrupt routine is no longer in progress, then pops the top two bytes from the stack and reloads the program counter. execution of the interrupted program continues from where it left off. note: a simple ret instruction would also return execution to the interrupted program, but it would have left the interrupt control sys tem thinking an inte rrupt was still in prog ress, making future interrupts impossible. table 24. vector addresses source vector address int0 0003h 2nd usart 004bh timer 0 000bh i2c 0043h int1 0013h timer 1 001bh usb 0033h 1st usart 0023h timer 2+exf2 002bh
power-saving mode upsd3212a, upsd3212c, upsd3212cv 48/181 6 power-saving mode two software selectable modes of reduced power consumption are implemented. 6.1 idle mode in idle mode, the following functions are switched off. cpu (halted) the following functions remain active during idle mode: external interrupts timer 0, timer 1, timer 2 pwm units usb interface usart 8-bit adc i 2 c interface note: interrupt or reset terminates the idle mode. 6.2 power-down mode system clock halted lvd logic remains active sram content remains unchanged the sfrs retain their value until a reset is asserted note: the only way to exit powe r-down mode is through a reset . 6.3 power control register the idle and power-down modes are activated by software via the pcon register. table 25. power-saving mode power consumption mode addr/data ports 1,3,4 pwm i 2 cusb idle maintain data maintain data active active active power-down maintain data maintain data disable disable disable table 26. pin status during idle and power-down mode sfr addr reg name bit register name reset value comments 76543210 87 pcon smod smod1 lvren adsfint rclk1 tclk1 pd idle 00 power ctrl
upsd3212a, upsd3212c, upsd3212cv power-saving mode 49/181 1. see the t2con register for det ails of the flag description 6.4 idle mode the instruction that sets pcon.0 is the last instruction executed in the normal operating mode before idle mode is activated. once in the idle mode, the cpu status is preserved in its entirety: stack pointer, program counter, program status word, accumulator, ram and all other registers maintain their data during idle mode. there are three ways to terminate the idle mode. 1. activation of any enabled interrupt w ill cause pcon.0 to be cleared by hardware terminating idle mode. the interrupt is se rviced, and following return from interrupt instruction reti, the next instruction to be executed will be the one which follows the instruction that wrote a logic '1' to pcon.0. 2. external hardware reset: the hardware reset is required to be active for two machine cycle to complete the reset operation. 3. internal reset: the microcontroller restarts after 3 machine cycles in all cases. 6.5 power-down mode the instruction that sets pcon.1 is the last executed prior to going into the power-down mode. once in power-down mode, the oscillato r is stopped. th e contents of the on-chip ram and the special function register are preserved. the power-down mode c an be terminated by an external reset. table 27. description of the pcon bits bit symbol function 7 smod double baud data rate bit uart 6 smod1 double baud data rate bit 2nd uart 5 lvren lvr disable bit (active high) 4 adsfint enable adc interrupt 3 rclk1 (1) received clock flag (uart 2) 2tclk1 (1) transmit clock flag (uart 2) 1 pd activate power-down mode (high enable) 0 idl activate idle mode (high enable)
i/o ports (mcu module) upsd3212a, upsd3212c, upsd3212cv 50/181 7 i/o ports (mcu module) the mcu module has five ports: port 0, port 1, port 2, port 3, and port 4. (refer to the psd module section on i/o ports a,b,c and d). ports p0 and p2 are dedicated for the external address and data bus and is not available in the 52-pin package devices. port 1- port 3 are the same as in the standard 8032 microcontrollers, with the exception of the additional special peripheral functions. a ll ports are bi-directional. pins of which the alternative function is not used may be used as normal bi-directional i/o. the use of port 1-port 4 pins as alternative functions are carried out automatically by the upsd321xx devices provided the associated sfr bit is set high. the following sfr registers ( ta b l e 2 9 , ta bl e 3 0 , and ta b l e 3 1 ) are used to control the mapping of alternate functions onto the i/o port bits. port 1 alternate functions are controlled using the p1sfs register, except for timer 2 and the 2nd uart which are enabled by their configuration registers. p1.0 to p1.3 are default to gpio after reset. port 3 pins 6 and 7 have been modified from the standard 8032. these pins that were used for read and write control signals are now gpio or i 2 c bus pins. the read and write pins are assigned to dedicated pins. port 3 (i 2 c) and port 4 alternate functions are controlled using the p3sfs and p4sfs special function selection registers. after a reset, the i/o pins default to gpio. the alternate function is ena bled if the corresponding bit in the pxsfs register is set to '1.' other port 3 alternative functions (uart, interrupt, and timer/counter) are enabled by their configuration register and do not require setting of the bits in p3sfs. table 28. i/o port functions port name main function alternate port 1 gpio timer 2 - bits 0,1 2nd uart - bits 2,3 adc - bits 4..7 port 3 gpio uart - bits 0,1 interrupt - bits 2,3 timers - bits 4,5 i 2 c - bits 6,7 port 4 gpio pwm - bits 3..7 usb +/- usb +/- only table 29. p1sfs (91h) 76543210 0=port 1.7 1=ach3 0=port 1.6 1=ach2 0=port 1.5 1=ach1 0=port 1.4 1=ach0 bits are reserved bits are reserved
upsd3212a, upsd3212c, upsd 3212cv i/o ports (mcu module) 51/181 7.1 port type and description figure 16. port type and description (part 1) table 30. p3sfs (93h) 76543210 0 = port 3.7 1 = scl from i 2 c unit 0 = port 3.6 1 = sda from i 2 c unit bits are reserved table 31. p4sfs (94h) 76543210 0=port 4.7 1=pwm 4 0=port 4.6 1=pwm 3 0=port 4.5 1=pwm 2 0=port 4.4 1=pwm 1 0=port 4.3 1=pwm 0 0=port 4.2 1=v sync 0=port 4.1 1=ddc - scl 0=port 4.0 1=ddc - sda ai06653 symbol circuit description in / out reset i ? schmitt input with internal pull-up cmos compatible interface nfc : 400ns wr, rd,ale, psen o output only xtal1, xtal2 i o on-chip oscillator on-chip feedback resistor stop in the power down mode external clock input available cmos compatible interface port0 i/o bidirectional i/o port schmitt input address output ( push-pull ) cmos compatible interface nfc xon
i/o ports (mcu module) upsd3212a, upsd3212c, upsd3212cv 52/181 figure 17. port type and description (part 2) ai07428b symbol circuit function in/ out port1 <3:0>, port3, port4<7:3,1:0> port2 i/o port4.2 bidirectional i/o port with internal pull-ups schmitt input cmos compatible interface bidirectional i/o port with internal pull-ups schmitt input. ttl compatible interface port1 < 7:4 > i/o bidirectional i/o port with internal pull-ups schmitt input cmos compatible interface analog input option i/o an_enb usb?, usb+ bidirectional i/o port schmitt input ttl compatible interface i/o + ?
upsd3212a, upsd3212c, upsd3212cv oscillator 53/181 8 oscillator the oscillator circuit of the upsd321xx devices is a single stage inverting amplifier in a pierce oscillator configurati on. the circuitry between xtal1 and xtal2 is basically an inverter biased to the transfer point. either a crystal or ceramic resonator can be used as the feedback element to complete the oscillator circuit. both ar e operated in pa rallel resonance. xtal1 is the high gain amplifier input, and xtal2 is the output. to drive the upsd321xx devices externally, xtal1 is driven from an external source and xtal2 left open-circuit. figure 18. oscillator ai06620 xtal1 xtal2 8 to 40 mhz xtal1 xtal2 external clock
supervisory upsd3212a, upsd3212c, upsd3212cv 54/181 9 supervisory there are four ways to invoke a reset and initialize the upsd321xx devices. 1. via the external reset pin 2. via the internal lvr block 3. via usb bus reset signaling 4. via watchdog timer (wdt) the reset mechanism is illustrated in figure 19 . each reset source will cause an internal reset signal active. the cpu responds by executing an internal reset and puts the internal registers in a defined state. this internal reset is also routed as an active low reset input to the psd module. figure 19. reset configuration 9.1 external reset the reset pin is connected to a schmitt trigger for noise reduction. a reset is accomplished by holding the reset pin low for at least 1ms at power up while the oscillator is running. refer to ac spec on other reset timing requirements. 9.2 low v dd voltage reset an internal reset is generated by the lvr circuit when the v dd drops below the reset threshold. after v dd reaching back up to the reset threshold, the reset signal will remain asserted for 10ms before it is released. on initial power-up the lvr is enabled (default). after power-up the lvr can be disabled via the lvren bit in the pcon register. note: the lvr logic is still functional in both the idle and power-down modes. the reset threshold: 5 v operation: 4 v 0.25 v 3.3 v operation: 2.5 v 0.2 v this logic supports approximately 0.1 v of hysteresis and 1 s noise-cancelling delay. ai06621 reset cpu & peri. noise cancel lvr s q r cpu clock sync 10ms timer usb reset rste wdt psd_rst ? active low 10ms at 40mhz 50ms at 8mhz
upsd3212a, upsd3212c, upsd3212cv supervisory 55/181 9.3 watchdog timer overflow the watchdog timer generates an internal reset when its 22-bit counter overflows. see watchdog timer section for details. 9.4 usb reset the usb reset is generated by a detection on the usb bus reset signal. a single-end zero on its upstream port for 4 to 8 times will set rstf bit in uista register. if bit 6 (rste) of the uien register is set, the detection will also generate the reset signal to reset the cpu and other peripherals in the mcu.
watchdog timer upsd3212a, upsd3212c, upsd3212cv 56/181 10 watchdog timer the hardware watchdog timer (wdt) resets the upsd321xx devices when it overflows. the wdt is intended as a recovery method in situations where the cpu may be subjected to a software upset. to prevent a system reset t he timer must be reloaded in time by the application software. if the processor suffers a hardware/software malfunction, the software will fail to reload the timer. this failure will result in a reset upon overfl ow thus preventing the processor running out of control. in the idle mode the watchdog timer and reset circuitry remain active. the wdt consists of a 22-bit counter, the watchdog timer reset (wdrst) sfr and watchdog key register (wdkey). since the wdt is automatically enabled while the processor is running. the user only needs to be concerned with servicing it. the 22-bit counter overflows when it reaches 4194304 (3fffffh). the wdt increments once every machine cycle. this means the user must reset the wdt at least every 4194304 machine cycles (1.258 seconds at 40mhz). to reset the wdt the user must write a value between 00-7eh to the wdrst register. the value that is written to the wdrst is loaded to the 7msb of the 22-bit counter. this allows the user to pre-loaded the counter to an initial value to generate a flexible watchdog time out period. writing a ?00? to wdrst clears the counter. the watchdog timer is controlled by the watchdog key register, wdkey. only pattern 01010101 (=55h), disables the watchdog timer. the rest of pattern combinations will keep the watchdog timer enabled. th is security key will prevent the watchdog timer from being terminated abnormally when the function of the watchdog timer is needed. in idle mode, the oscillator continues to ru n. to prevent the wd t from resetting the processor while in idle, the user should always set up a time r that will periodically exit idle, service the wdt, and re-enter idle mode. watchdog reset pulse width depends on the clock frequency. the reset period is tf osc x 12 x 2 22 . the reset pulse width is tf osc x 12 x 2 15 . table 32. watchdog timer key register (wdkey: 0aeh) 76543210 wdkey7 wdkey6 wdkey5 wdkey4 wdkey3 wdkey2 wdkey1 wdkey0 table 33. description of the wdkey bits bit symbol function 7 to 0 wdkey7 to wdkey0 enable or disable watchdog timer. 01010101 (=55h): disable watchdog timer. others: enable watchdog timer
upsd3212a, upsd3212c, upsd3212cv watchdog timer 57/181 figure 20. reset pulse width 1. the watchdog timer (wdt) is enabled at power-u p or reset and must be served or disabled. table 34. watchdog timer clear register (wdrst: 0a6h) 76543210 reserved wdrst6 wdrst5 wdrst4 wdrst3 wdrst2 wdrst1 wdrst0 table 35. description of the wdrst bits bit symbol function 7?reserved 6 to 0 wdrst6 to wdrst0 to reset watchdog timer, write any value beteen 00h and 7eh to this register. this value is loaded to the 7 most si gnificant bits of the 22-bit counter. for example: mov wdrst,#1eh reset period (1.258 second at 40mhz) (about 6.291 seconds at 8mhz) reset pulse width (about 10ms at 40mhz, about 50ms at 8mhz) ai06823
timer/counters (timer 0, timer 1 and timer 2) upsd3212a, upsd3212c, upsd3212cv 58/181 11 timer/counters (timer 0, timer 1 and timer 2) the upsd321xx devices has three 16-bit timer/counter registers: timer 0, timer 1 and timer 2. all of them can be configured to operate either as timers or event counters and are compatible with standard 8032 architecture. in the ?timer? function, the register is incremented every machine cycle. thus, one can think of it as counting machine cycles. since a mach ine cycle consists of 6 cpu clock periods, the count rate is 1/6 of the cpu clock frequency or 1/ 12 of the oscillator frequency (f osc ). in the ?counter? function, the register is incremented in response to a 1-to-0 transition at its corresponding external input pin, t0 or t1. in this function, the external input is sampled during s5p2 of every machine cycle. when the samples show a high in one cycle and a low in the next cycle, the count is incremented. the new count value appears in the register during s3p1 of the cycle following the one in which the transition was detected. since it takes 2 machine cycles (24 f osc clock periods) to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the f osc . there are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled at least once before it changes, it should be held for at least one full cycle. in addition to the ?timer? or ?counter? selection, timer 0 and timer 1 have four operating modes from which to select. 11.1 timer 0 and timer 1 the ?timer? or ?counter? function is selected by control bits c/ t in the special function register tmod. these timer/counters have four operating modes, which are selected by bit-pairs (m1, m0) in tmod. modes 0, 1, and 2 are the same for timers/ counters. mode 3 is different. the four operating modes are de-scribed in the following text. table 36. control register (tcon) 76543210 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 table 37. description of the tcon bits bit symbol function 7tf1 timer 1 overflow flag. set by hardware on timer/counter overflow. cleared by hardware when processor vectors to interrupt routine 6tr1 timer 1 run control bit. set/cleared by software to turn timer/counter on or off 5tf0 timer 0 overflow flag. set by hardier on timer/counter overflow. cleared by hardware when processor vectors to interrupt routine 4tr0 timer 0 run control bit. set/cleared by software to turn timer/counter on or off 3ie1 interrupt 1 edge flag. set by hardware when external interrupt edge detected. cleared when interrupt processed 2it1 interrupt 1 type control bit. set/clea red by software to specify falling- edge/low-level triggered external interrupt
upsd3212a, upsd3212c, upsd3212cv timer/counters (timer 0, timer 1 and timer 2) 59/181 11.1.1 mode 0 putting either timer into mode 0 makes it look like an 8048 timer, which is an 8-bit counter with a divide-by-32 prescaler. figure 21 shows the mode 0 operation as it applies to timer 1. in this mode, the timer register is configured as a 13-bit register. as the count rolls over from all '1s' to all '0s,' it sets the timer interrupt flag tf1. the counted input is enabled to the timer when tr1 = 1 and either gate = 0 or /int1 = 1. (setting gate = 1 allows the timer to be controlled by exter nal input /int1, to facilitate pulse width measurements). tr1 is a control bit in the special function register tcon (tcon control register). gate is in tmod. the 13-bit register consists of all 8 bits of th 1 and the lower 5 bits of tl1. the upper 3 bits of tl1 are indeterminate and should be ignored. setting the run flag does not clear the registers. mode 0 operation is the same for the timer 0 as for timer 1. substitute tr0, tf0, and /int0 for the corresponding timer 1 signals in figure 21 there are two different gate bits, one for timer 1 and one for timer0. figure 21. timer/counter mode 0: 13-bit counter 11.1.2 mode 1 mode 1 is the same as mode 0, except that the timer register is being run with all 16 bits. 1ie0 interrupt 0 edge flag. set by hardware when external interrupt edge detected. cleared when interrupt processed 0it0 interrupt 0 type control bit. set/clea red by software to specify falling- edge/low-level triggered external interrupt table 37. description of the tcon bits bit symbol function ai06622 f osc tf1 interrupt gate tr1 int1 pin t1 pin control tl1 (5 bits) th1 (8 bits) c/t = 0 c/t = 1 12 table 38. tmod register (tmod) 76543210 gate c/t m1 m0 gate c/t m1 m0
timer/counters (timer 0, timer 1 and timer 2) upsd3212a, upsd3212c, upsd3212cv 60/181 11.1.3 mode 2 mode 2 configures the timer register as an 8-bit counter (tl1) with automatic reload, as shown in figure 22 . overflow from tl1 not only sets tf1, but also reloads tl1 with the contents of th1, which is preset by software. the reload leaves th1 unchanged. mode 2 operation is the same for timer/counter 0. figure 22. timer/counter mode 2: 8-bit auto-reload table 39. description of the tmod bits bit symbol timer function 7gate timer1 gating control when set. timer/counter 1 is enabled only while int1 pin is high and tr1 control pin is set. when cleared, timer 1 is enabled whenever tr1 control bit is set 6c/t timer or counter selector, cleared for timer operation (input from internal system clock); set for counter ope ration (input from t1 input pin) 5 m1 (m1,m0)=(0,0): 13-bit timer/counter, th1, with tl1 as 5-bit prescaler (m1,m0)=(0,1): 16-bit timer/counter. th1 and tl1 are cascaded. there is no prescaler. (m1,m0)=(1,0): 8-bit auto-reload timer/counter. th1 holds a value which is to be reloaded into tl1 each time it overflows (m1,m0)=(1,1): timer/counter 1 stopped 4m0 3gate timer0 gating control when set. timer/counter 0 is enabled only while int0 pin is high and tr0 control pin is set. when cleared, timer 0 is enabled whenever tr0 control bit is set 2c/t timer or counter selector, cleared for timer operation (input from internal system clock); set for counter ope ration (input from t0 input pin) 1 m1 (m1,m0)=(0,0): 13-bit timer/counter, th0, with tl0 as 5-bit prescaler (m1,m0)=(0,1): 16-bit timer/counter. th0 and tl0 are cascaded. there is no prescaler. (m1,m0)=(1,0): 8-bit auto-reload timer/counter. th0 holds a value which is to be reloaded into tl0 each time it overflows (m1,m0)=(1,1): tl0 is an 8-bit time r/counter controlled by the standard timer 0 control bits. th0 is an 8- bit timer only cont rolled by timer 1 control bits 0m0 ai06623 f osc tf1 interrupt gate tr1 int1 pin t1 pin control tl1 (8 bits) th1 (8 bits) c/t = 0 c/t = 1 12
upsd3212a, upsd3212c, upsd3212cv timer/counters (timer 0, timer 1 and timer 2) 61/181 11.1.4 mode 3 timer 1 in mode 3 simply holds its count. the effect is the same as setting tr1 = 0. timer 0 in mode 3 establishes tl0 and th0 as two separate counters. the logic for mode 3 on timer 0 is shown in figure 23 . tl0 uses the timer 0 control bits: c/t, gate, tr0, int0, and tf0. th0 is locked into a timer function (counting machine cycles) and takes over the use of tr1 and tf1 from timer 1. thus, th0 now controls the ?timer 1? interrupt. mode 3 is provided for applications requiring an extra 8-bit timer on the counter. with timer 0 in mode 3, an upsd321xx devices can look like it has three timer/counters. when timer 0 is in mode 3, timer 1 can be turned on and off by switching it out of and into its own mode 3, or can still be us ed by the serial port as a baud rate ge nerator, or in fact, in any application not requiring an interrupt. figure 23. timer/counter mode 3: two 8-bit counters 11.2 timer 2 like timers 0 and 1, timer 2 can operate as either an event timer or as an event counter. this is selected by bit c/t2 in the special fu nction register t2con. it has three operating modes: capture, auto-reload, and baud rate generator, which are selected by bits in the t2con as shown in ta bl e 4 1 . in the capture mode there are two options which are selected by bit exen2 in t2con. if exen2 = 0, then ti mer 2 is a 16-bit timer or counter which upon overflowing sets bit tf2, the timer 2 overflow bit, which can be used to generate an interrupt. if exen2 = 1, then timer 2 still does the above, but with the added feature that a 1-to-0 transition at external input t2ex causes the current value in the timer 2 registers, tl2 and th2, to be captured into registers rcap2l and rcap2h, respectively. in addition, the transition at t2ex causes bit exf2 in t2con to be set, and exf2 like tf2 can generate an interrupt. the ca pture mode is illustrated in figure 24 . in the auto-reload mode, there are again two options, which are selected by bit exen2 in t2con. if exen2 = 0, then when timer 2 rolls over it not only sets tf2 but also causes the timer 2 registers to be reloaded with the 16-bit value in registers rcap2l and rcap2h, which are preset by software. if exen2 = 1, then timer 2 still does the above, but with the added feature that a 1-to-0 transition at ex ternal input t2ex will also trigger the 16 -bit reload ai06624 f osc tf0 interrupt gate tr0 int0 pin t0 pin control tl0 (8 bits) c/t = 0 c/t = 1 12 f osc tf1 interrupt control th1 (8 bits) 12 tr1
timer/counters (timer 0, timer 1 and timer 2) upsd3212a, upsd3212c, upsd3212cv 62/181 and set exf2. auto-reload mode is illustrated in the standard serial interface (uart) figure 25 . the baud rate generation mode is selected by (rclk, rclk1)=1 and/or (tclk, tclk1)=1. it is described in conjunction with the serial port. 1. the rclk1 and tclk1 bits in the pcon register control uart 2, and have the same function as rclk and tclk. table 40. timer/counter 2 control register (t2con) 76543210 tf2 exf2 rclk tclk exen2 tr2 c/t 2cp/rl 2 table 41. description of the t2con bits bit symbol function 7tf2 timer 2 overflow flag. set by a timer 2 overflow, and must be cleared by software. tf2 will not be set when either (rclk, rclk1)=1 or (tclk, tclk)=1 6 exf2 timer 2 external flag set when either a capture or reload is caused by a negative transition on t2ex and exen2=1. when timer 2 interrupt is enabled, exf2=1 will cause the cpu to vector to the timer 2 interrupt routine. exf2 must be cleared by software 5 rclk (1) receive clock flag (uart 1). when set, causes the serial port to use timer 2 overflow pulses for its receive clock in modes 1 and 3. tclk=0 causes timer 1 overflow to be used for the receive clock 4tclk (1) transmit clock flag (uart 1). when set, causes the serial port to use timer 2 overflow pulses for its transmit clock in modes 1 and 3. tclk=0 causes timer 1 overflow to be used for the transmit clock 3 exen2 timer 2 external enable flag. when set, allows a capture or reload to occur as a result of a negative transition on t2ex if timer 2 is not being used to clock the serial port. exen2=0 causes time 2 to ignore events at t2ex 2 tr2 start/stop control for timer 2. a logic 1 starts the timer 1c/t 2 timer or counter select for timer 2. cleared for timer operation (input from internal system clock, t cpu ); set for external event counter operation (negative edge triggered) 0cp/rl 2 capture/reload flag. when set, capture will occur on negative transition of t2ex if exen2=1. when cleared, auto-rel oad will occur eith er with timer 2 overflows, or negative transitions of t2ex when exen2=1. when either (rclk, rclk1)=1 or (tclk, tclk)=1, this bit is ignored, and timer is forced to auto-reload on timer 2 overflow
upsd3212a, upsd3212c, upsd3212cv timer/counters (timer 0, timer 1 and timer 2) 63/181 1. = falling edge figure 24. timer 2 in capture mode table 42. timer/counter2 operating modes mode t2con t2mod decn t2con exen p1.1 t2ex remarks input clock rxclk or txclk cp/r l 2 tr2 internal external (p1.0/t2) 16-bit auto- reload 0 0 1 0 0 x reload upon overflow f osc /12 max f osc /24 0010 1 reload trigger (falling edge) 0 0 1 1 x 0 down counting 0 0 1 1 x 1 up counting 16-bit capture 011x 0x 16-bit timer/counter (only up counting) f osc /12 max f osc /24 011x 1 capture (th1,tl2) (rcap2h,rcap2l) baud rate generator 1x1x 0x no overflow interrupt request (tf2) f osc /12 max f osc /24 1x1x 1 extra external interrupt (timer 2) off x x 0 x x x timer 2 stops ? ? ai06625 f osc tf2 capture tr2 t2 pin control tl2 (8 bits) th2 (8 bits) c/t2 = 0 c/t2 = 1 12 exp2 control exen2 rcap2l rcap2h t2ex pin timer 2 interrupt transition detector
timer/counters (timer 0, timer 1 and timer 2) upsd3212a, upsd3212c, upsd3212cv 64/181 figure 25. timer 2 in auto-reload mode ai06626 f osc tf2 reload tr2 t2 pin control tl2 (8 bits) th2 (8 bits) c/t2 = 0 c/t2 = 1 12 exp2 control exen2 rcap2l rcap2h t2ex pin timer 2 interrupt transition detector
upsd3212a, upsd3212c, upsd3212cv standard serial interface (uart) 65/181 12 standard serial interface (uart) the upsd321xx devices provides two standard 8032 uart serial ports. the first port is connected to pin p3.0 (rx) and p3.1 (tx). the second port is connected to pin p1.2 (rx) and p1.3(tx). the operation of the two serial ports are the same and are controlled by the scon and scon2 registers. the serial port is full duplex, meaning it can transmit and receive simultaneously. it is also receive-buffered, meaning it can commence reception of a second byte before a previously received byte has been read from the register. (however, if th e first byte st ill has not been read by the time reception of th e second byte is complete, one of the bytes will be lost.) the serial port receive and transmit registers are both accessed at special function register sbuf (or sbuf2 for the second serial port). writing to sbuf loads the transmit register, and reading sbuf accesses a physically separate receive register. the serial port can operate in 4 modes: mode 0, 1, 2 or 3. mode 0 serial data enters and exits through rxd. txd outputs the shift clock. 8 bits are transmitted/received (lsb first). the baud rate is fixed at 1/12 the f osc . mode 1 10 bits are transmitted (through txd) or received (through rxd): a start bit (0), 8 data bits (lsb first), and a stop bit (1). on receive, the stop bit goes into rb8 in special function register scon. the baud rate is variable. mode 2 11 bits are transmitted (through txd) or received (through rxd): start bit (0), 8 data bits (lsb first), a programmable 9th data bit, and a stop bit (1). on transmit, the 9th data bit (tb8 in scon) can be assigned the value of ?0? or ?1?. or, for example, the parity bit (p, in the psw) could be moved into tb8. on receive, the 9th data bit goes into rb8 in special function register scon, while the stop bit is ignored. the baud rate is programmable to either 1/32 or 1/64 the oscillator frequency. mode 3 11 bits are transmitted (through txd) or received (through rxd): a start bit (0), 8 data bits (lsb first), a programmable 9th data bit, and a stop bit (1). in fact, mode 3 is the same as mode 2 in all respects except baud rate. the baud rate in mode 3 is variable. in all four modes, transmission is initiated by any instruction that uses sbuf as a destination register. reception is initiated in mode 0 by the condition ri = 0 and ren = 1. reception is initiated in the other modes by the incoming start bit if ren = 1. 12.1 multiprocessor communications modes 2 and 3 have a special provision for multiprocessor communications. in these modes, 9 data bits are received. the 9th one goes into rb8. then comes a stop bit. the port can be programmed such that when the stop bit is re ceived, the serial port interrupt will
standard serial interface (uart) upsd3212a, upsd3212c, upsd3212cv 66/181 be activated only if rb8 = 1. this feature is enabled by setting bit sm2 in scon. a way to use this feature in multi-processor systems is as follows: when the master processor wants to transmit a block of data to one of several slaves, it first sends out an address byte which identifies the target slave. an address byte differs from a data byte in that the 9th bit is '1' in an address byte and 0 in a data byte. with sm2 = 1, no slave will be interrupted by a data byte. an ad- dress byte, however, will interrupt all slaves, so that each slave can examine the received byte and see if it is being addressed. the addressed slave will clear its sm2 bit and prepare to receiv e the data bytes that will be coming. the slaves that weren?t being addressed leave their sm2s set and go on about their business, ignoring the coming data bytes. sm2 has no effect in mode 0, and in mode 1 can be used to check the validity of the stop bit. in a mode 1 reception, if sm2 = 1, th e receive interrupt will not be activated unless a valid stop bit is received. 12.2 serial port control register the serial port control and status register is the special function register scon (scon2 for the second port), shown in figure 26 . this register contains not only the mode selection bits, but also the 9th data bit for transmit and receive (tb8 and rb8), and the serial port interrupt bits (ti and ri). table 43. serial port control register (scon) 76543210 sm0 sm1 sm2 ren tb8 rb8 ti ri table 44. description of the scon bits bit symbol function 7 sm0 (sm1,sm0)=(0,0): shift register. baud rate = f osc /12 (sm1,sm0)=(1,0): 8-bit uart. baud rate = variable (sm1,sm0)=(0,1): 8-bit uart. baud rate = f osc /64 or f osc /32 (sm1,sm0)=(1,1): 8-bit uart. baud rate = variable 6sm1 5sm2 enables the multiprocessor communication features in mode 2 and 3. in mode 2 or 3, if sm2 is set to '1,' ri will not be activated if its received 8th data bit (rb8) is '0.' in mode 1, if sm 2=1, ri will not be activated if a valid stop bit was not received. in mode 0, sm2 should be '0' 4ren enables serial reception. set by software to enable reception. clear by software to disable reception 3tb8 the 8th data bit that will be transmitted in modes 2 and 3. set or clear by software as desired 2rb8 in modes 2 and 3, this bit contains the 8th data bit that was received. in mode 1, if sm2=0, rb8 is the snap bi t that was received. in mode 0, rb8 is not used
upsd3212a, upsd3212c, upsd3212cv standard serial interface (uart) 67/181 12.2.1 baud rates the baud rate in mode 0 is fixed: mode 0 baud rate = f osc / 12 the baud rate in mode 2 depends on the value of bit smod = 0 (which is the value on reset), the baud rate is 1/64 the oscillator frequency. if smod = 1, the baud rate is 1/32 the oscillator frequency. mode 2 baud rate = (2 smod / 64) x f osc in the upsd321xx devices, the baud rates in modes 1 and 3 are determined by the timer 1 overflow rate. 12.2.2 using timer 1 to generate baud rates when timer 1 is used as the baud rate generator, the baud rates in modes 1 and 3 are determined by the timer 1 overflow rate and the value of smod as follows: modes 1 and 3 baud rate = (2 smod / 32) x (timer 1 overflow rate) the timer 1 interrupt should be disabled in this application. the timer itself can be configured for either ?timer? or ?counter? operation, and in any of its 3 running modes. in the most typical applications, it is configured for ?timer? operation, in the auto-reload mode (high nibble of tmod = 0010b). in that case the baud rate is given by the formula: modes 1 and 3 baud rate = (2 smod / 32) x (f osc / (12 x [256 ? (th1)])) one can achieve very low baud rates with timer 1 by leaving the timer 1 interrupt enabled, and configuring the timer to run as a 16-bit timer (high nibble of tmod = 0001b), and using the timer 1 interrupt to do a 16-bit software reload. figure 21 lists various commonly used baud rates and how they can be obtained from timer 1. 12.2.3 using timer/counter 2 to generate baud rates in the upsd321xx devices, timer 2 selected as the baud rate generator by setting tclk and/or rclk (see figure 21 timer/ counter 2 control register (t2con)). note: the baud rate for transmit and receive can be simultaneously different. setting rclk and/or tclk puts timer into its baud rate generator mode. the rclk and tclk bits in the t2con register configure uart 1. the rclk1 and tclk1 bits in the pcon register configure uart 2. the baud rate generator mode is similar to the auto-reload mmode, in that a roll over in th2 causes the timer 2 registers to be reloaded with the 16-bit value in registers rcap2h and rcap2l, which are preset by software. 1ti transmit interrupt flag. set by hardware at the end of the 8th bit time in mode 0, or at the beginning of the stop bit in the other modes, in any serial transmission. must be cleared by software 0ri receive interrupt flag. set by hardware at the end of the 8th bit time in mode 0, or halfway through the stop bit in the other modes, in any serial reception (except for sm2). must be cleared by software table 44. description of the scon bits (continued) bit symbol function
standard serial interface (uart) upsd3212a, upsd3212c, upsd3212cv 68/181 now, the baud rates in modes 1 and 3 are determined at timer 2?s overflow rate as follows: modes 1 and 3 baud rate = timer 2 overflow rate / 16 the timer can be configured for either ?timer? or ?counter? operation. in the most typical applications, it is configured for ?timer? operation (c/t2 = 0). ?timer? operation is a little different for timer 2 when it?s being used as a baud rate generator. normally, as a timer it would increment every machine cycle (thus at the 1/6 the cpu clock frequency). in the case, the baud rate is given by the formula: modes 1 and 3 baud baud rate = f osc / (32 x [65536 ? (rcap2h, rcap2l)] where (rcap2h, rcap2l) is the content of rc2h and rc2l taken as a 16-bit unsigned integer. timer 2 also be used as the baud rate generati ng mode. this mode is valid only if rclk + tclk = 1 in t2con or in pcon. note: a roll-over in th2 does not set tf2, and w ill not generate an interrup t. therefore, the timer interrupt does not have to be disabled when timer 2 is in the baud rate generator mode. note: if exen2 is set, a 1-to-0 tr ansition in t2ex will set exf2 but will not cause a reload from (rcap2h, rcap2l) to (th2, tl2). thus when timer 2 is in use as a baud rate generator, t2ex can be used as an extra external interrupt, if desired. it should be noted that when timer 2 is running (tr2 = 1) in ?timer? function in the baud rate generator mode, one should not try to read or write th2 or tl2. under these conditions the timer is being incremented every state time, and the results of a read or write may not be accurate. the rc registers may be read, but should not be written to, because a write might overlap a reload and c ause write and/or reload errors. turn the timer off (clear tr2) before accessing the timer 2 or rc registers, in this case. 12.2.4 more about mode 0 serial data enters and exits through rxd. txd outputs the shift clock. 8 bits are transmitted/received: 8 data bits (lsb first). the baud rate is fixed at 1/12 the f osc . table 45. timer 1-generated commonly used baud rates baud rate f osc smod timer 1 c/t mode reload value mode 0 max: 1mhz 12mhz x x x x mode 2 max: 375k 12mhz 1 x x x modes 1, 3: 62.5k 12mhz 1 0 2 ffh 19.2k 11.059mhz 1 0 2 fdh 9.6k 11.059mhz 0 0 2 fdh 4.8k 11.059mhz 0 0 2 fah 2.4k 11.059mhz 0 0 2 f4h 1.2k 11.059mhz 0 0 2 e8h 137.5 11.059mhz 0 0 2 1dh 110 6mhz 0 0 2 72h 110 12mhz 0 0 1 feebh
upsd3212a, upsd3212c, upsd3212cv standard serial interface (uart) 69/181 figure 26 shows a simplified functional diagram of the serial port in mode 0, and associated timing. transmission is initiated by any instruction th at uses sbuf as a destination register. the ?write to sbuf? signal at s6p2 also loads a '1' into the 9th position of the transmit shift register and tells the tx control block to commence a transmission. the internal timing is such that one full machine cycle will elapse between ?write to sb uf? and activation of send. send enables the output of the shift register to the alternate out-put function line of rxd and also enable shift clock to the alternate output function line of txd. shift clock is low during s3, s4, and s5 of every machine cycle, and high during s6, s1, and s2. at s6p2 of every machine cycle in which send is ac tive, the contents of the transmit shift are shifted to the right one position. as data bits shift out to the right, zeros come in from the left. when the msb of the data byte is at the output position of the shift register, then the '1' that was initially loaded into the 9th position, is just to the left of the msb, and all positions to the left of that contain zeros. this condition flags the tx control block to do one last shift and then deactivate send and set t1. both of these actions occur at s1p1. both of these actions occur at s1p1 of the 10th machine cycle after ?write to sbuf.? reception is initiated by the condition ren = 1 and r1 = 0. at s6p2 of the next machine cycle, the rx control unit writes the bits 11111110 to the receive shift register, and in the next clock phase activates receive. receive enables shift clock to the alternate output function line of txd. shift clock makes transitions at s3p1 and s6p1 of every machine cycle in which receive is active, the contents of the receive shift register are shifted to the left one position. the value that comes in from the right is the value that was sampled at the rxd pin at s5p2 of the same machine cycle. as data bits come in from the right, '1s' shift out to the left. when the '0' that was initially loaded into the right-most position arrives at the left-most position in the shift register, it flags the rx control block to do one last shift and load sbuf. at s1p1 of the 10th machine cycle after the write to scon that cleared ri, receive is cleared as ri is set. 12.2.5 more about mode 1 ten bits are transmitted (through txd), or received (through rxd): a start bit (0), 8 data bits (lsb first). and a stop bit (1). on receive, the stop bit goes into rb8 in scon. in the upsd321xx devices the baud rate is determined by the timer 1 or timer 2 overflow rate. figure 28 shows a simplified functional diagram of the serial port in mode 1, and associated timings for transmit receive. transmission is initiated by any instruction th at uses sbuf as a destination register. the ?write to sbuf? signal also loads a '1' into the 9th bit position of the transmit shift register and flags the tx control unit that a transmi ssion is requested. transmission actually commences at s1p1 of the machine cycle following the next rollover in the divide-by-16 counter. (thus, the bit times are synchronized to the divide-by-16 counter, not to the ?write to sbuf? signal.) the transmission begins with activation of sen d which puts the start bit at txd. one bit time later, data is activated, which enables the output bit of the transmit shift register to txd. the first shift pulse occurs one bit time after that.
standard serial interface (uart) upsd3212a, upsd3212c, upsd3212cv 70/181 as data bits shift out to the right, zeros are clocked in from the left. when the msb of the data byte is at the output position of the shift register, then the '1' that was initially loaded into the 9th position is just to the left of the msb, and all positions to the left of that contain zeros. this condition flags the tx control unit to do one last shift and then deactivate send and set ti. this occurs at the 10th divide-by-16 rollover after ?write to sbuf.? reception is initiated by a de tected 1-to-0 transition at rxd. for this purpose rxd is sampled at a rate of 16 times whatever baud rate has been established. when a transition is detected, the divide-by-16 counter is immediately reset, and 1ffh is written into the input shift register. resetting the divide-by-16 counter aligns its roll-overs with the boundaries of the incoming bit times. the 16 states of the counter divide each bit time into 16ths. at the 7th, 8th, and 9th counter states of each bit time, the bit detector samples the value of rxd. the value accepted is the value that was seen in at least 2 of the 3 samples. this is done for noise rejection. if the value accepted during the first bit time is not '0,' the receive circuits are reset and the unit goes back to looking for an-other 1-to-0 transition. this is to provide rejection of false start bits. if the start bit proves valid, it is shifted into the input shift register, and reception of the reset of the rest of the frame will proceed. as data bits come in from the right, '1s' shift out to the left. when the start bit arrives at the left-most position in the shift register (which in mode 1 is a 9-bit register), it flags the rx control block to do one last shift, load sbuf and rb8, and set ri. the signal to load sbuf and rb8, and to set ri, will be generated if, and only if, the following conditions are met at the time the final shift pulse is generated: 1. r1 = 0, and 2. either sm2 = 0, or the received stop bit = 1. if either of these two conditions is not met, the received frame is irretrievably lost. if both conditions are met, the stop bit goes into rb8, the 8 data bits go into sbuf, and ri is activated. at this time, whether the above conditions are met or not, the unit goes back to looking for a 1-to-0 transition in rxd. 12.2.6 more about modes 2 and 3 eleven bits are transmitted (through txd), or received (through rxd): a start bit (0), 8 data bits (lsb first), a programmable 9th data bit, and a stop bit (1). on transmit, the 9th data bit (tb8) can be assigned the value of '0' or '1.' on receive, the data bit goes into rb8 in scon. the baud rate is programmable to either 1/16 or 1/32 the cpu clock frequency in mode 2. mode 3 may have a variable baud rate generated from timer 1. figure 30 and figure 32 show a functional diagram of the serial port in modes 2 and 3. the receive portion is exactly the same as in mode 1. the transmit portion differs from mode 1 only in the 9th bit of the transmit shift register. transmission is initiated by any instruction th at uses sbuf as a destination register. the ?write to sbuf? signal also loads tb8 into the 9th bit position of the transmit shift register and flags the tx control unit that a transmission is requested. transmission commences at s1p1 of the machine cycle following the next roll-over in the divide-by-16 counter. (thus, the bit times are synchronized to the divide-by-16 counter, not to the ?write to sbuf? signal.) the transmission begins with activation of send, which puts the start bit at txd. one bit time later, data is activated, which enables the output bit of the transmit shift register to txd. the first shift pulse occurs one bit time af ter that. the first shift clocks a '1' (the stop bit) into the 9th bit position of the shift register. there-after, only zeros are clocked in. thus,
upsd3212a, upsd3212c, upsd3212cv standard serial interface (uart) 71/181 as data bits shift out to the right, zeros are clocked in from the left. when tb8 is at the out- put position of the shift register, then the stop bit is just to the left of tb8, and all positions to the left of that contain zeros. this condition flags the tx control unit to do one last shift and then deactivate send and set ti. this occurs at the 11th divide-by 16 rollover after ?write to subf.? reception is initiated by a de tected 1-to-0 transition at rxd. for this purpose rxd is sampled at a rate of 16 times whatever baud rate has been established. when a transition is detected, the divide-by-16 counter is immediately reset, and 1ffh is written to the input shift register. at the 7th, 8th, and 9th counter states of each bit time, the bit detector samples the value of r-d. the value accepted is the value that was seen in at least 2 of the 3 samples. if the value accepted during the first bit time is not '0,' the receive circuits are reset and the unit goes back to looking for another 1-to-0 transition. if the start bit proves valid, it is shifted into the input shift register, and reception of the rest of th e frame will proceed. as data bits come in from the right, '1s' shift out to the left. when the start bit arrives at the left-most position in the shift register (which in modes 2 and 3 is a 9-bit register), it flags the rx control block to do one last shift, load sbuf and rb8, and set ri. the signal to load sbuf and rb8, and to se t ri, will be generated if, and only if, the following conditions are met at the time the final shift pulse is generated: 1. ri = 0, and 2. either sm2 = 0, or the received 9th data bit = 1 if either of these conditions is not met, the received frame is irretrievably lost, and ri is not set. if both conditions are met, the received 9th data bit goes into rb8, and the first 8 data bits go into sbuf. one bit time later, whether the above conditions were met or not, the unit goes back to looking for a 1-to-0 transition at the rxd input.
standard serial interface (uart) upsd3212a, upsd3212c, upsd3212cv 72/181 figure 26. serial port mode 0 block diagram figure 27. serial port mode 0 waveforms ai06824 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift shift clock serial port interrupt s6 ren r1 rx clock start tx clock start shift shift send receive t r cl ds q 7 6 5 4 3 2 1 0 rxd p3.0 alt input function rxd p3.0 alt output function txd p3.1 alt output function ai06825 write to sbuf send shift rxd (data out) txd (shift clock) t write to scon ri receive shift rxd (data in) txd (shift clock) s6p2 s3p1 s6p1 clear ri receive transmit d0 d1 d2 d3 d4 d5 d6 d7 d0 d1 d2 d3 d4 d5 d6 d7
upsd3212a, upsd3212c, upsd3212cv standard serial interface (uart) 73/181 figure 28. serial port mode 1 block diagram figure 29. serial port mode 1 waveforms ai06826 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift serial port interrupt rx clock start tx clock start shift shift send load sbuf ti ri cl ds q 1ffh txd data rx detector rxd 1-to-0 transition detector 16 sample 16 2 tb8 timer1 overflow timer2 overflow 0 01 1 01 tclk rclk smod ai06843 write to sbuf data shift txd t1 rx clock rxd bit detector sample times shift ri s1p1 16 reset receive transmit d0 d1 d2 d3 d4 d5 d6 d7 send tx clock start bit stop bit d0 d1 d2 d3 d4 d5 d6 d7 start bit stop bit
standard serial interface (uart) upsd3212a, upsd3212c, upsd3212cv 74/181 figure 30. serial port mode 2 block diagram figure 31. serial port mode 2 waveforms ai06844 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift serial port interrupt rx clock start tx clock start shift shift send load sbuf ti ri cl ds q 1ffh txd data rx detector rxd 1-to-0 transition detector 16 sample 16 2 tb8 phase2 clock 1/2*f osc 01 smod ai06845 write to sbuf data shift txd ti rx clock rxd bit detector sample times shift ri s1p1 16 reset receive transmit d0 d1 d2 d3 d4 d5 d6 d7 send tx clock start bit stop bit tb8 d0 d1 d2 d3 d4 d5 d6 d7 start bit stop bit rb8 stop bit generator
upsd3212a, upsd3212c, upsd3212cv standard serial interface (uart) 75/181 figure 32. serial port mode 3 block diagram figure 33. serial port mode 3 waveforms ai06846 zero detector internal bus tx control rx control internal bus sbuf write to sbuf read sbuf load sbuf sbuf input shift register shift serial port interrupt rx clock start tx clock start shift shift send load sbuf ti ri cl ds q 1ffh txd data rx detector rxd 1-to-0 transition detector 16 sample 16 2 tb8 timer1 overflow timer2 overflow 0 01 1 01 tclk rclk smod ai06847 write to sbuf data shift txd ti rx clock rxd bit detector sample times shift ri s1p1 16 reset receive transmit d0 d1 d2 d3 d4 d5 d6 d7 send tx clock start bit stop bit tb8 d0 d1 d2 d3 d4 d5 d6 d7 start bit stop bit rb8 stop bit generator
analog-to-digital conv ertor (adc) upsd3212a, upsd3212c, upsd3212cv 76/181 13 analog-to-digital convertor (adc) the analog to digital (a/d) converter allows conversion of an analog input to a corresponding 8-bit digital value. the a/d module has four analog inputs, which are multiplexed into one sample and hold. the output of the sample and hold is the input into the converter, which generates the result via successive approximation. the analog supply voltage is connected to av ref of ladder resistance of a/d module. the a/d module has two registers which are the control register acon and a/d result register adat. the register acon, shown in ta bl e 4 7 , controls the operation of the a/d converter module. to use analog inputs, i/o is selected by p1sfs register. also an 8-bit prescaler ascl divides the main system clock input down to approximately 6mhz clock that is required for the adc logic. appropriate values need to be loaded into the prescaler based upon the main mcu clock frequency prior to use. the processing of conversion starts when the start bit adst is set to '1.' after one cycle, it is cleared by hardware. the register adat contains the results of the a/d conversion. when conversion is completed, the result is loaded into the adat the a/d conversion status bit adsf is set to '1.' the block diagram of the a/d module is shown in figure figure 34 . the a/d status bit adsf is set automatically when a/d conversion is completed, cleared when a/d conversion is in process. the ascl should be loaded with a value that results in a clock rate of approximately 6mhz for the adc using the following formula: adc clock input = (f osc / 2) / (prescaler register value +1) where f osc is the mcu clock input frequency. the conversion time for the adc can be calculated as follows: adc conversion time = 8 clock * 8bit s * (adc clock) ~= 10.67usec (at 6mhz) 13.1 adc interrupt the adsf bit in the acon register is set to '1' when the a/d conversion is complete. the status bit can be driven by the mcu, or it can be configured to generate a falling edge interrupt when the conversion is complete. the adsf interrupt is enabled by setting the adsfint bit in the pcon register. once the bit is set, the external int1 interrupt is disabled and the adsf interrupt takes over as int1. int1 must be configured as if it is an edge interrupt input. the inp1 pin (p3.3) is available for general i/o functions, or timer1 gate control.
upsd3212a, upsd3212c, upsd3212cv analog-to-digital convertor (adc) 77/181 figure 34. adc block diagram ai06627 input mux ach0 ach1 ach2 ach3 acon internal bus adat avref ladder resistor d ecode s/h successive approximation circuit conversion complete interrupt table 46. adc sfr memory map sfr addr reg name bit register name reset value comments 76543210 95 ascl 00 8-bit prescaler for adc clock 96 adat adat7 adat6 adat5 adat4 adat3 adat2 adat1 adat0 00 adc data register 97 acon aden ads1 ads0 adst adsf 00 adc control register table 47. description of the acon bits bit symbol function 7 to 6 ? reserved 5 aden adc enable bit: 0 : adc shut off and consumes no operating current 1 : enable adc 4?reserved 3 to 2 ads1, ads0 analog channel select 0, 0 0, 1 1, 0 1, 1 channel0 (ach0) channel1 (ach1) channel2 (ach2) channel3 (ach3) 1 adst adc start bit: 0 : force to zero 1 : start an adc; after one cycle, bit is cleared to '0'
analog-to-digital conv ertor (adc) upsd3212a, upsd3212c, upsd3212cv 78/181 0 adsf adc status bit: 0 : a/d conversion is in process 1 : a/d conversion is co mpleted, not in process table 48. adc clock input mcu clock frequency prescaler register value adc clock 40mhz 2 6.7mhz 36mhz 2 6mhz 24mhz 1 6mhz 12mhz 0 6mhz table 47. description of the acon bits (continued) bit symbol function
upsd3212a, upsd3212c, upsd3212 cv pulse width modulation (pwm) 79/181 14 pulse width modulation (pwm) the pwm block has the following features: four-channel, 8-bit pwm unit with 16-bit prescaler one-channel, 8-bit unit with programmable frequency and pulse width pwm output with programmable polarity 14.1 4-channel pwm unit (pwm 0-3) the 8-bit counter of a pwm counts module 256 (i.e., from 0 to 255, inclusive). the value held in the 8-bit counter is compared to the contents of the special function register (pwm 0-3) of the corresponding pwm. the polarity of the pwm outputs is programmable and selected by the pwml bit in pwmcon register. provided the contents of a pwm 0-3 register is greater than the counter value, the corresponding pwm output is set high (with pwml = 0). when the contents of this register is less than or equal to the counter value, the corresponding pwm output is set low (with pwml = 0). the pulse-width-ratio is therefore defined by the contents of the corresponding special function register (pwm 0-3) of a pwm. by loading the corresponding special fu nction register (pwm 0-3) with either 00h or ffh, the pwm output can be retained at a constant high or low level respectively (with pwml = 0). for each pwm unit, there is a 16-bit prescaler that are used to divide the main system clock to form the input clock for the corresponding pwm unit. this prescaler is used to define the desired repetition rate for the pwm unit. sfr registers b1h - b2h are used to hold the 16-bit divisor values. the repetition frequency of the pwm output is given by: fpwm 8 = (f osc / prescaler0) / (2 x 256) and the input clock frequency to the pwm counters is = f osc / 2 / (prescaler data value + 1) see section 7: i/o ports (mcu module) for more information on how to configure the port 4 pin as pwm output.
pulse width modulation (pwm) upsd3212a, upsd3212c, upsd3212cv 80/181 figure 35. four-channel 8-bit pwm block diagram ai06647 8-bit pwm0-pwm3 comparators registers 8-bit pwm0-pwm3 comparators 8 8 8-bit counter x 4 8-bit pwm0-pwm3 data registers 8 x 4 port4.3 port4.4 port4.5 port4.6 overflow clock load 16-bit prescaler register (b2h,b1h) 16 16-bit prescaler counter f osc /2 cpu rd/wr cpu rd/wr load pwmcon bit5 (pwme) pwmcon bit7 (pwml) 4 8 data bus x 4 8 8 table 49. pwm sfr memory map sfr addr reg name bit register name reset value comments 76543210 a1 pwmcon pwml pwmp pwme cf g4 cfg3 cfg2 cfg1 cfg0 00 pwm control polarity a2 pwm0 00 pwm0 output duty cycle a3 pwm1 00 pwm1 output duty cycle a4 pwm2 00 pwm2 output duty cycle a5 pwm3 00 pwm3 output duty cycle aa pwm4p 00 pwm 4 period ab pwm4w 00 pwm 4 pulse width b1 pscl0l 00 prescaler 0 low (8-bit)
upsd3212a, upsd3212c, upsd3212 cv pulse width modulation (pwm) 81/181 pwmcon register bit definition: pwml = pwm 0-3 polarity control pwmp = pwm 4 polarity control pwme = pwm enable (0 = disabled, 1= enabled) cfg3..cfg0 = pwm 0-3 output (0 = open drain; 1 = push-pull) cfg4 = pwm 4 output (0 = open drain; 1 = push-pull) 14.2 programmable period 8-bit pwm the pwm 4 channel can be programmed to provide a pwm output with variable pulse width and period. the pwm 4 has a 16-bit prescaler, an 8-bit counter, a pulse width register, and a period register. the pulse width register defines the pwm pulse width time, while the period register defines the period of the pwm. the input clock to the prescaler is f osc /2. the pwm 4 channel is assigned to port 4.7. figure 36. programmable 4-channel pwm block diagram b2 pscl0h 00 prescaler 0 high (8-bit) b3 pscl1l 00 prescaler 1 low (8-bit) b4 pscl1h 00 prescaler 1 high (8-bit) table 49. pwm sfr memory map (continued) sfr addr reg name bit register name reset value comments 76543210 ai07091 port 4.7 16-bit prescaler register (b4h, b3h) 16-bit prescaler counter 8-bit counter 8-bit pwm4p register (period) 8-bit pwm4 comparator register 8-bit pwm4 comparator pwm4 control match cpu rd/wr load load clock reset pwmcon bit 6 (pwmp) data bus cpu rd/wr f osc / 2 pwmcon bit 5 (pwme) 8 16 8 8 8 8 8-bit pwm4w register (width) 8-bit pwm4 comparator register 8-bit pwm4 comparator 8 88 8 8
pulse width modulation (pwm) upsd3212a, upsd3212c, upsd3212cv 82/181 14.3 pwm 4-channel operation the 16-bit prescaler1 divides the input clock (f osc /2) to the desired frequency, the resulting clock runs the 8-bit counter of the pwm 4 channel. the input clock frequency to the pwm 4 counter is: f pwm4 = (f osc /2)/(prescaler1 data value +1) when the prescaler1 register (b4h, b3h) is set to data value '0,' the maximum input clock frequency to the pwm 4 counter is f osc /2 and can be as high as 20mhz. the pwm 4 counter is a free-running, 8-bit counter. the output of the counter is compared to the compare registers, which are loaded with data from the pulse width register (pwm4w, abh) and the period register (pwm4p, aah). the pulse width register defines the pulse duration or the pulse width, while the period register defines the period of the pwm. when the pwm 4 channel is enabled, the register values are loaded into the comparator registers and are compared to the counter output. when the content of the counter is equal to or greater than the value in the pulse width register, it sets the pwm 4 output to low (with pwmp bit = 0). when the period register equals to the pwm4 counter, the counter is cleared, and the pwm 4 channel output is set to logic 'high' level (beginning of the next pwm pulse). the period register cannot have a value of ?00? and its content should always be greater than the pulse width register. the prescaler1 register, pulse width register, and period register can be modified while the pwm 4 channel is active. the values of these registers are automatically loaded into the prescaler counter and comparator registers when the current pwm 4 period ends. the pwmcon register (bits 5 and 6) controls the enable/disable and polarity of the pwm 4 channel. figure 37. pwm 4 with programmable pulse width and frequency ai07090 pwm4 defined by pulse width register switch level reset counter defined by period register
upsd3212a, upsd3212c, upsd3212cv i 2 c interface 83/181 15 i 2 c interface there are two serial i 2 c ports implemented in the upsd321xx devices. the serial port supports the twin line i 2 c-bus, consists of a data line (sdax) and a clock line (sclx). depending on the configuration, the sda and scl lines may require pull-up resistors. sda1, scl1: the serial port line for ddc protocol sda2, scl2: the serial port line for general i 2 c bus connection in both i 2 c interfaces, these lines also function as i/o port lines as follows. sda1 / p4.0, scl1 / p4.1, sda2 / p3.6, scl2 / p3.7 the system is unique because data transport, clock generation, address recognition and bus control arbitration are all controlled by hardware. the i 2 c serial i/o has complete autonomy in byte handling and operates in 4 modes. master transmitter master receiver slave transmitter slave receiver these functions are controlled by the sfrs. sxcon: the control of byte handling and the operation of 4 mode. sxsta: the contents of its register may also be used as a vector to various service routines. sxdat: data shift register. sxadr: slave address register. slave address recognition is performed by on-chip h/w. figure 38. block diagram of the i 2 c bus serial i/o ai06649 sclx sdax bus clock generator arbitration and sync. logic shift register status register 70 slave address 70 control register 70 70 internal bus table 50. serial control register (sxcon: s1con, s2con) 76543210 cr2 enii sta sto addr aa cr1 cr0
i 2 c interface upsd3212a, upsd3212c, upsd3212cv 84/181 table 51. description of the sxcon bits bit symbol function 7cr2 this bit along with bits cr1and cr0 determines the serial clock frequency when sio is in the master mode. 6enii enable iic. when eni1 = 0, the iic is disabled. sda and scl outputs are in the high impedance state. 5sta start flag. when this bit is set, the sio h/w checks the status of the i 2 c- bus and generates a start condition if t he bus free. if the bus is busy, the sio will generate a repeated start condition when this bit is set. 4sto stop flag. with this bi t set while in master mode a stop condition is generated. when a stop condition is detected on the i 2 c-bus, the i 2 c hardware clears the sto flag. note: this bit have to be set before 1 cycle interrupt period of stop. that is, if this bit is set, stop condition in master mode is generated after 1 cycle interrupt period. 3 addr this bit is set when address byte was received. must be cleared by software. 2aa acknowledge enable signal. if this bit is set, an acknowledge (low level to sda) is returned during the acknowledge clock pulse on the scl line when: ? own slave address is received ? a data byte is received while the device is programmed to be a master receiver ? a data byte is received while the device is a selected slave receiver. when this bit is reset, no acknowledge is returned. sio release sda line as high during the acknowledge clock pulse. 1cr1 these two bits along with the cr2 bit determine the serial clock frequency when sio is in the master mode. 0cr0 table 52. selection of the serial clock frequency scl in master mode cr2 cr1 cr0 f osc divisor bit rate (khz) at f osc 12 mhz 24 mhz 36 mhz 40 mhz 0 0 0 16 375 750 x x 0 0 1 24 250 500 750 833 0 1 0 30 200 400 600 666 0 1 1 60 100 200 300 333 1 0 0 120 50 100 150 166 1 0 1 240 25 50 75 83 1 1 0 480 12.5 25 37.5 41 1 1 1 960 6.25 12.5 18.75 20
upsd3212a, upsd3212c, upsd3212cv i 2 c interface 85/181 15.1 serial status register (sxsta: s1sta, s2sta) sxsta is a ?read-only? register. the contents of this register may be used as a vector to a service routine. this optimized the response time of the software and consequently that of the i 2 c-bus. the status codes for all possible modes of the i 2 c-bus interface are given table ta bl e 5 4 . this flag is set, and an interrupt is generated, after any of the following events occur. 1. own slave address has been received during aa = 1: ack_int 2. the general call address has been received while gc(sxadr.0) = 1 and aa = 1: 3. a data byte has been received or transmitted in master mode (even if arbitration is lost): ack_int 4. a data byte has been received or transmitted as selected slave: ack_int 5. a stop condition is received as selected slave receiver or transmitter: stop_int 15.2 data shift register (sxdat: s1dat, s2dat) sxdat contains the serial data to be transmitted or data which has just been received. the msb (bit 7) is transmitted or received first; that is, data shifted from right to left. 1. interrupt flag bit (intr, sxsta bit 5) is cleared by hardware as reading sxsta register. 2. i 2 c interrupt flag (intr) can occur in below case. (except ddc2b mode at swenb=0) table 53. serial status register (sxsta) 76543210 gc stop intr tx_mode bbusy blost /ack_rep slv table 54. description of the sxsta bits bit symbol function 7 gc general call flag 6 stop stop flag. this bit is set when a stop condition is received 5intr (1,2) interrupt flag. this bit is set when an i2c interrupt condition is requested 4tx_mode transmission mode flag. this bit is set when the i2c is a tran smitter; otherwise this bit is reset 3bbusy bus busy flag. this bit is set when the bus is being used by another master; otherwise, this bit is reset 2blost bus lost flag. this bit is set when the master loses the bus contention; otherwise this bit is reset 1/ack_rep acknowledge response flag. this bit is set when the receiver transmits the not acknowledge signal this bit is reset when the receiver transmits the acknowledge signal 0slv slave mode flag. this bit is set when the i2c plays role in the slave mode; otherwise this bit is reset
i 2 c interface upsd3212a, upsd3212c, upsd3212cv 86/181 15.3 address register (sxadr: s1adr, s2adr) this 8-bit register may be loaded with the 7-bit slave address to which the controller will respond when programmed as a slave receive/transmitter. the start/stop hold time detection and system clock registers ( ta bl e 5 7 and ta b l e 5 8 ) are included in the i 2 c unit to specify the start/stop detection time to work with the large range of mcu frequency values supported. for example, with a system clock of 40mhz. 1. sla6 to sla0: own slave address. table 55. data shift register (sxdat: s1dat, s2dat) 76543210 sxdat7 sxdat6 sxdat5 sxdat4 sxdat3 sxdat2 sxdat1 sxdat0 table 56. address register (sxadr) 76543210 sla6 sla5 sla4 sla3 sla2 sla1 sla0 ? table 57. start /stop hold time detection register (s1setup, s2setup) address register name reset value note sfr d1h s1setup 00h to control the start/stop hol d time detection for the ddc module in slave mode d2h s2setup 00h to control the start/stop hol d time detection for the multi-master i2c module in slave mode table 58. system clock of 40mhz s1setup, s2setup register value number of sample clock (f osc /2 -> 50ns) required start/stop hold time note 00h 1ea 50ns when bit 7 (enable bit) = 0, the number of sample clock is 1ea (ignore bit 6 to bit 0) 80h 1ea 50ns 81h 2ea 100ns 82h 3ea 150ns ... ... ... 8bh 12ea 600ns fast mode i2c start/stop hold time specification ... ... ... ffh 128ea 6000ns
upsd3212a, upsd3212c, upsd3212cv i 2 c interface 87/181 table 59. system clock setup examples system clock s1setup, s2setup register value number of sample clock required start/stop hold time 40mhz (f osc /2 -> 50ns) 8bh 12 ea 600ns 30mhz (f osc /2 -> 66.6ns) 89h 9 ea 600ns 20mhz (f osc /2 -> 100ns) 86h 6 ea 600ns 8mhz (f osc /2 -> 250ns) 83h 3 ea 750ns
usb hardware upsd3212a, upsd3212c, upsd3212cv 88/181 16 usb hardware the characteristics of usb hardware are as follows: complies with the universal serial bus specification rev. 1.1 integrated sie (serial interface engine), fifo memory and transceiver low speed (1.5mbit/s) device capability supports control endpoint0 and interrupt endpoint1 and 2 usb clock input must be 6mhz (requires mcu clock frequency to be 12, 24, or 36mhz). the analog front-end is an on-chip generic usb transceiver. it is designed to allow voltage levels equal to v dd from the standard logic to interface with the physical layer of the universal serial bus. it is capa ble of receiving and transmitting serial data at low speed (1.5mb/s). the sie is the digital-front-end of the usb bloc k. this module recovers the 1.5mhz clock, detects the usb sync word and handles all low-level usb protocols and error checking. the bit-clock recovery circuit recovers the clock from the incoming usb data stream and is able to track jitter and frequency drift according to the usb specification. the sie also translates the electrical usb signals into bytes or sig nals. depending upon the device usb address and the usb endpoint. address, the usb data is directed to the correct endpoint on sie interface. the data transfer of this h/w could be of type control or interrupt. the device?s usb address and the enabling of the endpoints are programmable in the sie configuration header. 16.1 usb related registers the usb block is controlled via seven registers in the memory: (uadr, ucon0, ucon1, ucon2, uista, uien, and usta). three memory locations on chip which communicate the usb block are: usb endpoint0 data transmit register (udt0) usb endpoint0 data receive register (udr0) usb endpoint1 data transmit register (udt1) table 60. usb address register (uadr: 0eeh) 76543210 usben uadd6 uadd5 uadd4 uadd3 uadd2 uadd1 uadd0
upsd3212a, upsd3212c, upsd3212cv usb hardware 89/181 table 61. description of the uadr bits bit symbol r/w function 7 usben r/w usb function enable bit. when usben is clear, the usb module will not respond to any tokens from host. reset clears this bit. 6 to 0 uadd6 to uadd0 r/w specify the usb address of the device. reset clears these bits. table 62. usb interrupt enable register (uien: 0e9h) 76543210 suspndi rste rstfie txd0ie rxd0ie txd1ie eopie resumi table 63. description of the uien bits bit symbol r/w function 7 suspndi r/w enable suspnd interrupt 6rster/w enable usb reset; also resets the cpu and psd modules when bit is set to '1.' 5 rstfie r/w enable rstf (usb bus reset flag) interrupt 4 txd0ie r/w enable txd0 interrupt 3 rxd0ie r/w enable rxd0 interrupt 2 txd1ie r/w enable txd1 interrupt 1 eopie r/w enable eop interrupt 0 resumi r/w enable usb resume interrupt when it is the suspend mode table 64. usb interrupt status register (uista: 0e8h) 76543210 suspnd ? rstf txd0f rxd0f txd1f eopf resumf table 65. description of the uista bits bit symbol r/w function 7 suspnd r/w usb suspend mode flag. to save power, this bit should be set if a 3ms constant idle state is detected on usb bus. setting this bit stops the clock to the usb and causes the usb module to enter suspend mode. software must clear this bit after the resume flag (resumf) is set while this resume interrupt flag is serviced 6 ? ? reserved 5rstfr usb reset flag. this bit is set when a valid reset signal state is detected on the d+ and d- lines. when the rste bit in the uien register is set, this reset detection will also generate an internal reset signal to reset the cpu and other peripherals including the usb module.
usb hardware upsd3212a, upsd3212c, upsd3212cv 90/181 4txd0fr/w endpoint0 data transmit flag. this bit is set after the data stored in endpoint 0 transmit buffers has been sent and an ack handshake packet from the host is received. once the next set of data is ready in the transmit buffers, software must clear this flag. to enable the next data packet transmission, tx0e must also be set. if txd0f bit is not cleared, a nak handshake will be returned in the next in transactions. reset clears this bit. 3rxd0fr/w endpoint0 data receive flag. this bit is set after the usb module has received a data packet and responded with ack handshake packet. software must clear this flag after all of the received data has been read. software must also set rx0e bit to one to enable the next data packet reception. if rxd0f bit is not cleared, a nak handshake will be returned in the next out transaction. reset clears this bit. 2txd1fr/w endpoint1 / endpoint2 data transmit flag. this bit is shared by endpoints 1 and endpoints 2. it is set after the data stored in the shared endpoint 1/ endpoint 2 transmit buffer has been sent and an ack handshake packet from the host is received. once th e next set of data is ready in the transmit buffers, software must clear this flag. to enable the next data packet transmission, tx1e must also be set. if txd1f bit is not cleared, a nak handshake will be returned in the next in transaction. reset clears this bit. 1 eopf r/w end of packet flag. this bit is set when a valid end of packet sequence is detected on the d+ and d-line. software must clear this flag. reset clears this bit. 0 resumf r/w resume flag. this bit is set when usb bus activity is detected while the suspnd bit is set. software must clear this flag. reset clears this bit. table 66. usb endpoint0 transmit control register (ucon0: 0eah) 76543210 tseq0 stall0 tx0e rx0e tp0siz3 tp0siz2 tp0siz1 tp0siz0 table 65. description of the uista bits (continued) bit symbol r/w function
upsd3212a, upsd3212c, upsd3212cv usb hardware 91/181 table 67. description of the ucon0 bits bit symbol r/w function 7 tseq0 r/w endpoint0 data sequence bit. (0=data0, 1=data1) this bit determines which type of data packet (data0 or data1) will be sent during the ne xt in transaction. toggling of this bit must be controlled by software. reset clears this bit 6 stall0 r/w endpoint0 force stall bit. this bit causes endpoint 0 to return a stall handshake when polled by either an in or out token by the usb host controller. the usb hardware clears this bit when a setup token is received. reset clears this bit. 5tx0er/w endpoint0 transmit enable. this bit enables a transmit to occur when the usb host controller sends an in token to endpoint 0. software should set this bit when data is ready to be transmitted. it must be cleared by software when no more endpoint 0 data needs to be transmitted. if this bit is '0' or the txd0f is set, the usb will respond with a nak handshake to any endpoint 0 in tokens. reset clears this bit. 4rx0er/w endpoint0 receive enable. this bit enables a receive to occur when the usb host controller sends an out token to endpoint 0. software should set this bit when data is ready to be received. it must be cleared by software when data cannot be received. if this bit is '0' or the rxd0f is set, the usb will respond with a nak handshake to an y endpoint 0 out tokens. reset clears this bit. 3 to 0 tp0siz3 to tp0siz0 r/w the number of transmit data bytes. these bits are cleared by reset . table 68. usb endpoint1 (and 2) transmit control register (ucon1: 0ebh) 76543210 tseq1 ep12sel tx1e fresum tp1siz3 tp1siz2 tp1siz1 tp1siz0
usb hardware upsd3212a, upsd3212c, upsd3212cv 92/181 table 69. description of the ucon1 bits bit symbol r/w function 7 tseq1 r/w endpoint 1/ endpoint 2 transmit data packet pid. (0=data0, 1=data1) this bit determines which type of data packet (data0 or data1) will be sent during the next in transaction directed to endpoint 1 or endpoint 2. toggling of this bit must be controlled by software. reset clears this bit. 6 ep12sel r/w endpoint 1/ endpoint 2 transmit selection. (0=endpoint 1, 1=endpoint 2) this bit specifies whether the data inside the registers udt1 are used for endpoint 1 or endpoint 2. if all the conditions for a successful endpoint 2 usb response to a hosts in token are satisfied (txd1f=0, tx1e=1 , stall2=0, and ep2e=1) except that the ep12sel bit is configured for endpoint 1, the usb responds with a nak handshake packet. reset clears this bit. 5tx1er/w endpoint1 / endpoint2 transmit enable. this bit enables a transmit to occur when the usb host controller send an in token to endpoint 1 or endpoint 2. the appropriate endpoint enable bit, ep1e or ep2e bit in the ucon2 register, should also be set. software should set the tx1e bit when data is ready to be transmitted. it must be cleared by software when no more data needs to be transmitted. if this bit is '0 ' or txd1f is set, the usb will respond with a nak handshake to any endpoint 1 or endpoint 2 directed in token. reset clears this bit. 4fresumr/w force resume. this bit forces a resume state (?k? on non-idle state) on the usb data lines to initiate a re mote wake-up. software should control the timing of the forced resume to be between 10ms and 15ms. setting this bit will not cause the resumf bit to set. 3 to 0 tp1siz3 to tp1siz0 r/w the number of transmit data bytes. these bits are cleared by reset . table 70. usb control register (ucon2: 0ech) 76543210 ? ? ? sout ep2e ep1e stall2 stall1 table 71. description of the ucon2 bits bit symbol r/w function 7 to 5 ? ? reserved 4 sout r/w status out is used to automatically respond to the out of a control read transfer 3 ep2e r/w endpoint2 enable. reset clears this bit
upsd3212a, upsd3212c, upsd3212cv usb hardware 93/181 the uscl 8-bit prescaler register for usb is at e1h. the uscl should be loaded with a value that results in a clock rate of 6 mhz for the usb using the following formula: usb clock input = (f osc / 2) / (prescaler register value +1) where f osc is the mcu clock input frequency. note: usb works only with the mcu clock frequencies of 12, 24, or 36 mhz. the prescaler values for these frequencies are 0, 1, and 2. 2 ep1e r/w endpoint1 enable. reset clears this bit 1 stall2 r/w endpoint2 force stall bit. reset clears this bit 0 stall1 r/w endpoint1 force stall bit. reset clears this bit table 72. usb endpoint0 status register (usta: 0edh) 76543210 rseq setup in out rp0siz3 rp0siz2 rp0siz1 rp0siz0 table 73. description of the usta bits bit symbol r/w function 7 rseq r/w endpoint0 receive data packe t pid. (0=data0, 1=data1) this bit will be compared with the type of data packet last received for endpoint0 6 setup r setup token detect bit. this bit is set when the received token packet is a sepup token, pid = b1101. 5inr in token detect bit. this bit is set when the received token packet is an in token. 4outr out token detect bit. this bit is set when the received token packet is an out token. 3 to 0 rp0siz3 to rp0siz0 r the number of data bytes received in a data packet table 74. usb endpoint0 data receive register (udr0: 0efh) 76543210 udr0.7 udr0.6 udr0.5 udr0.4 udr0.3 udr0.2 udr0.1 udr0.0 table 75. usb endpoint0 data transmit register (udt0: 0e7h) 76543210 udt0.7 udt0.6 udt0.5 udt0.4 udt0.3 udt0.2 udt0.1 udt0.0 table 76. usb endpoint1 data transmit register (udt1: 0e6h) 76543210 udt1.7 udt1.6 udt1.5 udt1.4 udt1.3 udt1.2 udt1.1 udt1.0 table 71. description of the ucon2 bits (continued) bit symbol r/w function
usb hardware upsd3212a, upsd3212c, upsd3212cv 94/181 16.2 transceiver 16.2.1 usb physical layer characteristics the following section describes the upsd321xx devices compliance to the chapter 7 electrical section of the usb specification, re vision 1.1. the section contains all signaling, and physical layer specifications necessary to describe a low speed usb function. table 77. usb sfr memory map sfr add r reg name bit register name reset value comments 7 6543210 e1 uscl 00 8-bit prescaler for usb logic e6 udt1 udt1.7 udt1.6 udt1.5 udt1. 4 udt1.3 udt1.2 udt1.1 udt1.0 00 usb endpt1 data xmit e7 udt0 udt0.7 udt0.6 udt0.5 udt0. 4 udt0.3 udt0.2 udt0.1 udt0.0 00 usb endpt0 data xmit e8 uista suspnd ? rstf txd0f rxd0f rxd1f eopf resumf 00 usb interrupt status e9 uien suspndi e rste rstfie txd0ie rxd0ie txd1ie eopie resumi e 00 usb interrupt enable ea ucon0 tseq0 stall0 tx0e rx0e tp0siz3 tp0siz2 tp0siz1 tp0siz0 00 usb endpt0 xmit control eb ucon1 tseq1 ep12se l ? fresu m tp1siz3 tp1siz2 tp1siz1 tp1siz0 00 usb endpt1 xmit control ec ucon2 ? ? ? sout ep2e ep1e stall2 stall1 00 usb control register ed usta rseq setup in out rp0siz3 rp0siz2 rp0siz1 rp0siz0 00 usb endpt0 status ee uadr usben uadd6 uadd5 uadd4 uadd3 uadd2 uadd1 uadd0 00 usb address register ef udr0 udr0.7 udr0.6 udr0.5 udr0.4 udr0.3 udr0.2 udr0.1 udr0.0 00 usb endpt0 data recv
upsd3212a, upsd3212c, upsd3212cv usb hardware 95/181 16.2.2 low speed driver characteristics the upsd321xx devices use a differential output driver to drive the low speed usb data signal onto the usb cable. the output swings between the differential high and low state are well balanced to minimize signal skew. the slew rate control on the driver minimizes the radiated noise and cross talk on the usb cable. the driver?s outputs support three-state operation to achieve bi-directional half dupl ex operation. the upsd321xx devices driver tolerates a voltage on the signal pins of -0.5 v to 3.6 v with respect to local ground reference without damage. the driver tolerates this voltage for 10.0s while the driver is active and driving, and tolerates this condition indefinitely when the driver is in its high impedance state. a low speed usb connection is made through an unshielded, untwisted wire cable a maximum of 3 meters in length. the rise and fall time of the signals on this cable are well controlled to reduce rf i emissions while limiting delays, signaling skews and distortions. the upsd321xx devices driver reaches the spec ified static signal leve ls with smooth rise and fall times, resulting in segments between low speed devices and the ports to which they are connected. figure 39. low speed driver signal waveforms 16.3 receiver characteristics upsd321xx devices have a differential input receiver which is able to accept the usb data signal. the receiver features an input sensitivity of at least 200 mv when both differential data inputs are in the range of at least 0.8 v to 2.5 v with respect to its local ground reference. this is the common mode range, as shown in figure 40 . the receiver tolerates static input voltages between -0.5 v to 3.8 v with respect to its local ground reference without damage. in addition to the differential receiver, there is a single-ended receiver for each of the two data lines. the single-ended receivers have a switching threshold between 0.8 v and 2.0 v (ttl inputs). ai06629 signal pins pass output spec levels with minimal reflections and ringing one bit time 1.5 mb/s v ss driver signal pins v se (min) v se (max)
usb hardware upsd3212a, upsd3212c, upsd3212cv 96/181 figure 40. differential input sensitivity over entire common mode range 16.4 external usb pull-up resistor the usb system specifies a pull-up resistor on the d- pin for low-speed peripherals. the usb spec 1.1 describes a 1.5 k pull-up resistor to a 3.3 v supply. an approved alternative method is a 7.5 k pull-up to the usb v cc supply. this alternative is defined for low-speed devices with an integrated cable. the chip is specified for the 7.5 k pull-up. this eliminates the need for an external 3.3 v regulator, or for a pin dedicated to providing a 3.3 v output from the chip. figure 41. usb data signal timing and voltage levels figure 42. receiver jitter tolerance ai06630 0.0 0.0 0.2 0.4 0.6 1.0 0.8 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 common mode input voltage (volts) minimum differential sensitivity (volts) ai06631 vcr d- d+ t r t f 10% 90% 90% 10% v oh v ol ai06632 t jr t jr1 t jr2 consecutive transitions n*t period +t jr1 t period paired transitions n*t period +t jr2 differential data lines
upsd3212a, upsd3212c, upsd3212cv usb hardware 97/181 figure 43. differential to eop transition skew and eop width figure 44. differential data jitter 1. v cc = 5 v 10%; v ss = 0 v; t a = 0 to 70c. 2. level guaranteed for range of v cc = 4.5 v to 5.5 v. 3. with rpu, external idle resistor, 7.5 2%, d- to v cc . table 78. transceiver dc characteristics symb parameter test conditions (1) min max unit v oh static output high 15 k 5% to gnd (2,3) 2.8 3.6 v v ol static output low notes 2, 3 ? 0.3 v v di differential input sensitivity |(d+) - (d-)|, figure 42 0.2 ? v v cm differential input common mode figure 42 0.8 2.5 v v se single ended receiver threshold ?0.82.0v c in transceiver capacitance ? ? 20 pf i io data line (d+, d-) leakage 0 < (d+,d-) < 3.3 ?10 10 a r pu external bus pull-up resistance, d- 7.5 k 2% to v cc 7.35 7.65 k r pd external bus pull-down resistance 15 k 5% 14.25 15.75 k receiver eop width t eopr1 , t eopr2 differential data lines source eop width: t eopt crossover point crossover point extended diff. data to se0 skew n*t period +t deop t period ai06634 consecutive transitions n*t period +t xjr1 t period crossover points paired transitions n*t period +t xjr2 differential data lines
usb hardware upsd3212a, upsd3212c, upsd3212cv 98/181 1. v cc = 5 v 10%; v ss = 0 v; t a = 0 to 70c. 2. level guaranteed for range of v cc = 4.5 v to 5.5 v. 3. with rpu, external idle resistor, 7.5 2%, d- to v cc . 4. c l of 50 pf (75 ns) to 350 pf (300 ns). 5. measured at crossover point of differential data signals. 6. usb specification indicates 330 ns. table 79. transceiver ac characteristics symb parameter test conditions (1) min max unit tdrate low speed data rate ave. bit rate (1.5mb/s 1.5%) 1.4775 1.5225 mbit/s tdjr1 receiver data jitter tolerance to next transition, figure 42 (5) ?75 75 ns tdjr2 differential input sensitivity for paired transition, figure 42 (5) ?45 45 ns tdeop differential to eop transition skew figure 43 (5) ?40 100 ns teopr1 eop width at receiver rejects as eop (5,6) 165 ? ns teopr2 eop width at receiver accepts as eop (5) 675 ? ns teopt source eop width ? ?1.25 1.50 s tudj1 differential driver jitter to next transition, figure 44 ?95 95 ns tudj2 differential driver jitter to paired transition, figure 44 ?150 150 ns tr usb data transition rise time notes 2, 3, 4 75 300 ns tf usb data transition fall time notes 2, 3, 4 75 300 ns trfm rise/fall time matching t r / t f 80 120 % v crs output signal crossover voltage ?1.32.0v
upsd3212a, upsd3212c, upsd3212cv psd module 99/181 17 psd module the psd module provides configurable program and data memories to the 8032 cpu core (mcu). in addition, it has its own set of i/o ports and a pld with 16 macrocells for general logic implementation. ports a,b,c, and d are general purpose programmable i/o ports that have a port architecture which is different from the i/o ports in the mcu module. the psd module communicates with the mcu module through the internal address, data bus (a0-a15, d0-d7) and control signals (rd , wr , psen , ale, reset ). the user defines the decoding pld in the psdsoft development tool and can map the resources in the psd module to any program or data address space. figure 45 shows the functional blocks in the psd module. 17.1 functional overview 512 kbit flash memory. this is the main fl ash memory. it is divided into four equal- sized blocks (16 kbytes each) that can be accessed with user-specified addresses. secondary 128 kbit flash boot memory. it is divided into two equal-sized blocks (8 kbytes each) thatat can be accessed with user-specified addresses. this secondary memory brings the abilit y to execute code and update the main flash concurrently. 16 kbit sram. cpld with 16 output micro cells (omcs} and up to 20 input micro cells (imcs). the cpld may be used to efficiently implement a variety of logic functions for internal and external control. examples include state machines, loadable shift registers, and loadable counters. decode pld (dpld) that decodes address for selection of memory blocks in the psd module. configurable i/o ports (port a,b,c and d) that can be used for the following functions: ? mcu i/os ? pld i/os ? latched mcu address output ? special function i/os ? i/o ports may be configured as open-drain outputs built-in jtag compliant serial port allows full-chip in-system programmability (isp). with it, you can program a blank device or reprogram a device in the factory or the field. internal page register that can be used to expand the 8032 mcu module address space by a factor of 256. internal programmable power management unit (pmu) that supports a low-power mode called power-down mode. the pmu can automatically detect a lack of the 8032 cpu core activity and put the psd module into power-down mode. erase/write cycles: flash memory - 100,000 minimum pld - 1,000 minimum data retention: 15 year minimum (for main flash memory, boot, pld and configuration bits)
psd module upsd3212a, upsd3212c, upsd3212cv 100/181 17.2 in-system pr ogramming (isp) using the jtag signals on port c, the entire psd module device can be programmed or erased without the use of the mcu. the primary flash memory can also be programmed in- system by the mcu executing the programming algorithms out of the secondary memory, or sram. the secondary memory can be programmed the same way by executing out of the primary flash memory. the pld or other psd module configuration blocks can be programmed through the jtag port or a device programmer. table ta b l e 8 0 indicates which programming methods can program different functional blocks of the psd module. figure 45. upsd321xx psd module block diagram bus interface wr_, rd_, psen_, ale, reset_, a0-a15 d0 ? d7 clkin (pd1) clkin clkin pld input bus prog. port port a prog. port port b power mangmt unit 512kbit primary flash memory 8 sectors vstdby pa0 ? pa7 pb0 ? pb7 prog. port port c prog. port port d pc0 ? pc7 pd1 ? pd2 address/data/control bus port a ,b & c 2 ext cs to port d 20 input macrocells port a ,b & c 73 73 128kbit secondary non-volatile memory (boot or data) 2 sectors runtime control and i/o registers perip i/o mode selects macrocell feedback or port input csiop flash isp cpld (cpld) 16 output macrocells flash decode pld ( dpld ) pld, configuration & flash memory loader jtag serial channel ( pc2 ) page register embedded algorithm sector selects sector selects global config. & security ai07431 8 bus interface 8032 bus
upsd3212a, upsd3212c, upsd3212cv psd module 101/181 table 80. methods of programming different functional blocks of the psd module functional block jtag programming device programmer iap primary flash memory yes yes yes secondary flash memory yes yes yes pld array (dpld and cpld) yes yes no psd module configuration yes yes no
development system upsd3212a, upsd3212c, upsd3212cv 102/181 18 development system upsd321xx devices are supported by psdsoft, a windows-based software development tool (windows-95, windows-98, windows-nt). a psd module design is quickly and easily produced in a point and click environment. the designer does not need to enter hardware description language (hdl) equations, unless desired, to define psd module pin functions and memory map information. the general design flow is shown in figure 46 . psdsoft is available from our web site (the address is given on the back page of this data sheet) or other distribution channels. psdsoft directly supports a low cost device programmer from st: flashlink (jtag). the programmer may be purchased through your local distributor/representative. upsd321xx devices are also supported by third party device programmers. see our web site for the current list. figure 46. psdsoft express development tool merge mcu firmware with psd module configuration psd programmer *.obj file flashlink (jtag) a composite object file is created containing mcu firmware and psd configuration c code generation generate c code specific to psd functions user's choice of 8032 compiler/linker *.obj file available for 3rd party programmers mcu firmware hex or s-record format ai05798 define general purpose logic in cpld point and click definition of combin- atorial and registered logic in cpld. access hdl is available if needed define psd pin and node functions point and click definition of psd pin functions, internal nodes, and mcu system memory map choose psd
upsd3212a, upsd3212c, upsd3212cv psd module register description and address offset 103/181 19 psd module register description and address offset ta bl e 8 1 shows the offset addresses to the psd module registers relative to the csiop base address. the csiop space is the 256 bytes of address that is allocated by the user to the internal psd module registers. ta bl e 8 1 provides brief descriptions of the registers in csiop space. the following section gives a more detailed description. 1. other registers that are not part of the i/o ports. table 81. register address offset register name port a port b port c port d other (1) description data in 00 01 10 11 reads port pin as input, mcu i/o input mode control 02 03 selects mode between mcu i/o or address out data out 04 05 12 13 stores data for output to port pins, mcu i/o output mode direction 06 07 14 15 configures port pin as input or output drive select 08 09 16 17 configures port pins as either cmos or open drain on some pins, while selecting high slew rate on other pins. input macrocell 0a 0b 18 reads input macrocells enable out 0c 0d 1a 1b reads the status of the output enable to the i/o port driver output macrocells ab 20 20 read ? reads output of macrocells ab write ? loads macrocell flip-flops output macrocells bc 21 21 read ? reads output of macrocells bc write ? loads macrocell flip-flops mask macrocells ab 22 22 blocks writing to the output macrocells ab mask macrocells bc 23 23 blocks writing to the output macrocells bc primary flash protection c0 read-only ? primary flash sector protection secondary flash memory protection c2 read-only ? psd module security and secondary flash memory sector protection pmmr0 b0 power management register 0 pmmr2 b4 power management register 2 page e0 page register vm e2 places psd module memory areas in program and/or data space on an individual basis.
psd module detailed operation upsd3212a, upsd3212c, upsd3212cv 104/181 20 psd module detailed operation as shown in figure 14 , the psd module consists of five major types of functional blocks: memory blocks pld blocks i/o ports power management unit (pmu) jtag interface the functions of each block are described in the following sections. many of the blocks perform multiple functions, and are user configurable.
upsd3212a, upsd3212c, upsd3212cv memory blocks 105/181 21 memory blocks the psd module has the following memory blocks: primary flash memory secondary flash memory sram the memory select signals for these blocks originate from the decode pld (dpld) and are user-defined in psdsoft express. 21.1 primary flash memory and secondary flash memory description the primary flash memory is divided evenly into four equal sectors. the secondary flash memory is divided into two equal sectors. each sector of either memory block can be separately protected from program and erase cycles. flash memory may be erased on a sector-by-sector basis. flash sector erasure may be suspended while data is read from other sectors of the block and then resumed after reading. during a program or erase cycle in flash memory, the status can be output on ready/busy (pc3). this pin is set up using psdsoft express configuration. 21.2 memory block select signals the dpld generates the select signals for all the internal memory blocks (see section 22: plds ). each of the four sectors of the primary flash memory has a select signal (fs0-fs3) which can contain up to three product terms. each of the two sectors of the secondary flash memory has a select signal (csboot0-csboot1) which can contain up to three product terms. having three product terms for each select signal allows a given sector to be mapped in program or data space. 21.2.1 ready/busy (pc3) this signal can be used to output the ready/busy status of the flash memory. the output on ready/busy (pc3) is a '0' (busy) when flash memory is being written to, or when flash memory is being erased. the output is a '1' (r eady) when no write or erase cycle is in progress. 21.2.2 memory operation the primary flash memory and secondary flash memory are addressed through the mcu bus. the mcu can access these memories in one of two ways: the mcu can execute a typical bus write or read operation . the mcu can execute a specific flash memory instruction that consists of several write and read operations. this involves writing specific data patterns to special addresses within the flash memory to invoke an embedded algorithm. these instructions are summarized in ta b l e 8 2 .
memory blocks upsd3212a, upsd3212c, upsd3212cv 106/181 typically, the mcu can read flash memory using read operations, just as it would read a rom device. however, flash memory can only be altered using specific erase and program instructions. for example, the mcu cannot write a single byte directly to flash memory as it would write a byte to ram. to program a byte into flash memory, the mcu must execute a program instruction, then test the status of the program cycle. this status test is achieved by a read operation or polling ready/busy (pc3). 21.3 instructions an instruction consists of a sequence of sp ecific operations. each received byte is sequentially decoded by the psd module and not executed as a standard write operation. the instruction is executed when the correct number of bytes are properly received and the time between two consecutive bytes is shorter than the time-out period. some instructions are structured to include read operations after the initial write operations. the instruction must be followed exactly. any invalid combination of instruction bytes or time-out between two consecutive bytes while addressing flash memory resets the device logic into read mode (flash me mory is read like a rom device). the flash memory supports the instructions summarized in ta b l e 8 2 : erase memory by chip or sector suspend or resume sector erase program a byte reset to read mode read sector protection status these instructions are detailed in ta bl e 8 2 . for efficient decoding of the instructions, the first two bytes of an instruction are the coded cycles and are followed by an instruction byte or confirmation byte. the coded cycles consist of writing the data aah to address x555h during the first cycle and da ta 55h to address xaaah during the second cycle. address signals a15-a12 are don?t care during the instruction write cycles. however, the appropriate sector select (fs0-fs3 or csboot0-csboot1) must be selected. the primary and secondary flash memories have the same instruction set (except for read primary flash identifier). the sector select signals determine which flash memory is to receive and execute the instruction. the primary flash memory is selected if any one of sector select (fs0-fs3) is high, and the secondary flash memory is selected if any one of sector select (csboot0-csboot1) is high. table 82. instructions instruction fs0-fs 3 or csboot0- csboot 1 cycle 1 cycle 2 cycle 3 cycle 4 cycle 5 cycle 6 cycle 7 read (5) 1 ?read? rd @ ra read sector protection (6,8,13) 1 aah@ x555h 55h@ xaaah 90h@ x555h read status @ xx02h program a flash byte (13) 1 aah@ x555h 55h@ xaaah a0h@ x555h pd@ pa
upsd3212a, upsd3212c, upsd3212cv memory blocks 107/181 1. all bus cycles are writ e bus cycles, except the ones with the ?read? label 2. all values are in hexadecimal. 3. x = don?t care. addresses of the form xxxxh, in this table, must be even addresses 4. ra = address of the memory location to be read 5. rd = data read from location ra during the read cycle 6. pa = address of the memory location to be prog rammed. addresses are latched on the falling edge of write strobe (wr , cntl0). 7. pa is an even address for psd in word programming mode. 8. pd = data word to be programmed at location pa . data is latched on the rising edge of write strobe (wr , cntl0) 9. sa = address of the sector to be erased or verified. the sector select (fs0-f s3 or csboot0-csboot1) of the sector to be erased, or verified, must be active (high). 10. sector select (fs0-fs3 or c sboot0-csboot1) signal s are active high, and are defined in psdsoft express. 11. only address bits a11-a0 ar e used in instruction decoding. 12. no unlock or instruction cycles are r equired when the device is in the read mode 13. the reset instruction is required to return to the read mode after reading the sector protection status, or if the error flag bit (dq5) goes high. 14. additional sectors to be erased must be written at the end of the sector erase instruction within 80s. 15. the data is 00h for an unprotected sector, and 01h for a protected sector. in the fourth cycle, the sector select is active, and (a1,a0)=(1,0) 16. the system may perform read and program cycles in non-erasing sectors, read the flash id or read the sector protection status when in the suspend sect or erase mode. the suspend sector erase instruction is valid only during a sector erase cycle. 17. the resume sector erase instruction is va lid only during the suspend sector erase mode. 18. the mcu cannot invoke these instructions while exec uting code from the same flash memory as that for which the instruction is intended. the mcu must retr ieve, for example, the code from the secondary flash memory when reading the sector protection status of the primary flash memory. 21.4 power-down instru ction and power-up mode 21.4.1 power-up mode the psd module internal logic is reset upon power-up to the read mode. sector select (fs0-fs3 and csboot0-csboot1) must be held low, and write strobe (wr , cntl0) high, during power-up for maximum security of the data contents and to remove the flash sector erase (7,13) 1 aah@ x555h 55h@ xaaah 80h@ x555h aah@ x555h 55h@ xaaah 30h@ sa 30h 7 @ next sa flash bulk erase (13) 1 aah@ x555h 55h@ xaaah 80h@ x555h aah@ x555h 55h@ xaaah 10h@ x555h suspend sector erase (11) 1 b0h@ xxxxh resume sector erase (12) 1 30h@ xxxxh reset (6) 1 f0h@ xxxxh table 82. instructions (continued) instruction fs0-fs 3 or csboot0- csboot 1 cycle 1 cycle 2 cycle 3 cycle 4 cycle 5 cycle 6 cycle 7
memory blocks upsd3212a, upsd3212c, upsd3212cv 108/181 possibility of a byte being written on the first edge of write strobe (wr , cntl0). any write cycle initiation is locked when v cc is below v lko . 21.5 read under typical conditions, the mcu may read the primary flash memory or the secondary flash memory using read operations just as it would a rom or ram device. alternately, the mcu may use read operations to obtain status information about a program or erase cycle that is currently in progress. lastly, the mcu may use instructions to read special data from these memory blocks. the following sections describe these read functions. 21.5.1 read memory contents primary flash memory and secondary flash memory are placed in the read mode after power-up, chip reset, or a re set flash instruction (see ta bl e 8 2 ). the mcu can read the memory contents of the primary flash memory or the secondary flash memory by using read operations any time the read operation is not part of an instruction. 21.5.2 read memory se ctor protection status the primary flash memory sector protection status is read with an instruction composed of 4 operations: 3 specific write oper ations and a read operation (see ta b l e 8 2 ). during the read operation, address bits a6, a1, and a0 must be '0,' '1,' and '0,' respectively, while sector select (fs0-fs3 or csboot0-csboot1) designates the flash memory sector whose protection has to be verified. the read operation produces 01h if the flash memory sector is protected, or 00h if the sector is not protected. the sector protection status for all nvm blocks (primary flash memory or secondary flash memory) can also be read by the mcu accessing the flash protection registers in psd i/o space. see section 21.8.1: flash memory sector protect for register definitions. 21.5.3 reading the era se/program status bits the flash memory provides several status bits to be used by the mcu to confirm the completion of an erase or program cycle of flash memory. these status bits minimize the time that the mcu spends performing these tasks and are defined in ta b l e 8 3 . the status bits can be read as many times as needed. for flash memory, the mcu can perform a read operation to obtain these status bits while an erase or program instruction is being executed by the embedded algorithm. see section 21.6: programming flash memory , for details. 21.5.4 data polling flag (dq7) when erasing or programming in flash memory , the data polling flag bit (dq7) outputs the complement of the bit being entered for programming/writing on the dq7 bit. once the
upsd3212a, upsd3212c, upsd3212cv memory blocks 109/181 program instruction or the write operation is completed, the true logic value is read on the data polling flag bit (dq7) (in a read operation). data polling is effective after the fourth writ e pulse (for a program instruction) or after the sixth write pulse (for an erase instruction). it must be performed at the address being programmed or at an address within the flash memory sector being erased. during an erase cycle, the data polling flag bit (dq7) outputs a '0.' after completion of the cycle, the data polling flag bit (dq7) output s the last bit programm ed (it is a '1' after erasing). if the byte to be programmed is in a protected flash memory sector, the instruction is ignored. if all the flash memory sect ors to be erased are protec ted, the data polling flag bit (dq7) is reset to '0' for about 100s, and then returns to the previous addressed byte. no erasure is performed. 21.5.5 toggle flag (dq6) the flash memory offers another way for determining when the program cycle is completed. during the internal write operation and when either the fs0-fs3 or csboot0-csboot1 is true, the toggle flag bit (dq6) toggles from '0' to '1' and '1' to '0' on subsequent attempts to read any byte of the memory. when the internal cycle is complete, the toggling stops and the data read on the data bus d0-d7 is the addressed memory byte. the devi ce is now accessible for a new read or write operation. the cycle is finished when two successive reads yield the same output data. the toggle flag bit (dq6) is effective after the fourth write pulse (for a program instruction) or after the sixth write pulse (for an erase instruction). if the byte to be programmed belongs to a protected flash memory sector, the instruction is ignored. if all the flash memory sectors selected for erasure are protected, the toggle flag bit (dq6) toggles to '0' for about 100s and then returns to the previous addressed byte. 21.5.6 error flag (dq5) during a normal program or erase cycle, the error flag bit (dq5) is to '0.' this bit is set to '1' when there is a failure during flash memory byte program, sector erase, or bulk erase cycle. in the case of flash memory programming, the error flag bit (dq5) indicates the attempt to program a flash memory bit from the programmed state, '0', to the erased state, '1,' which is not valid. the error flag bit (dq5) may also indicate a time-out condition while attempting to program a byte. in case of an error in a flash memory sector erase or byte program cycle, the flash memory sector in which the error occurred or to which the programmed byte belongs must no longer be used. other flas h memory sectors may still be us ed. the error flag bit (dq5) is reset after a reset flash instruction. 21.5.7 erase time-out flag (dq3) the erase time-out flag bit (dq3) reflects the time-out period allowed between two consecutive sector erase instructions. the erase time-out flag bit (dq3) is reset to '0' after
memory blocks upsd3212a, upsd3212c, upsd3212cv 110/181 a sector erase cycle for a time period of 100s + 20% unless an additional sector erase instruction is decoded. after this time period, or when the additional sector erase instruction is decoded, the erase time-out flag bit (dq3) is set to ?1?. 1. x = not guaranteed value, can be read either '1' or '0.' 2. dq7-dq0 represent the data bus bits, d7-d0. 3. fs0-fs3 and csboot0-c sboot1 are active high. 21.6 programming flash memory flash memory must be erased prior to being programmed. a byte of flash memory is erased to all '1's (ffh), and is programmed by setting selected bits to '0'. the mcu may erase flash memory all at once or by-sector, but not byte-by-byte. however, the mcu may program flash memory byte-by-byte. the primary and secondary flash memories require the mcu to send an instruction to program a byte or to erase sectors (see ta bl e 8 2 ). once the mcu issues a flash memory program or erase instruction, it must check for the status bits for completion. the embedded algorithms that are invoked support several means to provide status to the mcu. status may be checked using any of three methods: data polling, data to ggle, or ready/busy (pc3). 21.6.1 data polling polling on the data polling flag bit (dq7) is a method of checking whether a program or erase cycle is in progre ss or has completed. figure 47 shows the data polling algorithm. when the mcu issues a program instruction, the embedded algorithm begins. the mcu then reads the location of the byte to be programmed in flash memory to check status. the data polling flag bit (dq7) of this location be comes the complement of b7 of the original data byte to be programmed. the mcu continues to poll this location, comparing the data polling flag bit (dq7) and monito ring the error flag bit (dq5). when the data polling flag bit (dq7) matches b7 of the original data, and the error flag bit (dq5) remains '0,' the embedded algorithm is complete. if the error flag bit (dq5) is '1,' the mcu should test the data polling flag bit (dq7) again since the da ta polling flag bit (dq7) may have changed simultaneously with the error flag bit (dq5) (see figure 47 ). the error flag bit (dq5) is set if either an internal time-out occurred while the embedded algorithm attempted to program the byte or if the mcu attempted to program a '1' to a bit that was not erased (not erased is logic '0'). it is suggested (as with all flash memories) to read the location again after the embedded programming algorithm has completed, to compare the byte that was written to the flash memory with the byte that was intended to be written. table 83. status bit functional block fs0-fs3/ csboot0- csboot1 dq7 dq6 dq5 dq4 dq3 dq2 dq1 dq0 flash memory v ih data polling to g g l e flag error flag x erase time-out xxx
upsd3212a, upsd3212c, upsd3212cv memory blocks 111/181 when using the data polling method during an erase cycle, figure 47 still applies. however, the data polling flag bit (dq7) is '0' until the erase cycle is complete. a '1' on the error flag bit (dq5) indicates a time-out condition on the erase cycle; a '0' indicates no error. the mcu can read any location within the sector bei ng erased to get the data polling flag bit (dq7) and the error flag bit (dq5). psdsoft express generates ansi c code fu nctions which implement these data polling algorithms. figure 47. data polling flowchart 21.6.2 data toggle checking the toggle flag bit (dq6) is a method of determining whether a program or erase cycle is in progress or has completed. figure 48 shows the data toggle algorithm. when the mcu issues a program instruction, the embedded algorithm begins. the mcu then reads the location of the byte to be programmed in flash memory to check status. the toggle flag bit (dq6) of this location toggles each time the mcu reads this location until the embedded algorithm is complete. the mcu continues to read this location, checking the toggle flag bit (dq6) and monitoring the error flag bit (dq5). when the toggle flag bit (dq6) stops toggling (two consecutive reads yield the same value), and the error flag bit (dq5) remains '0,' the embedded algorithm is complete. if the error flag bit (dq5) is '1,' the mcu should test the toggle flag bit (dq6) again, since the toggle flag bit (dq6) may have changed simultaneously with the error flag bit (dq5) (see figure 48 ). the error flag bit (dq5) is set if either an internal time-out occurred while the embedded algorithm attempted to program the byte, or if the mcu attempted to program a '1' to a bit that was not erased (not erased is logic '0'). it is suggested (as with all flash memories) to read the location again after the embedded programming algorithm has completed, to compare the byte that was written to flash memory with the byte that was intended to be written. read dq5 & dq7 at valid address start read dq7 fail pass ai01369b dq7 = data yes no yes no dq5 = 1 dq7 = data yes no
memory blocks upsd3212a, upsd3212c, upsd3212cv 112/181 when using the data toggle method after an erase cycle, figure 48 still applies. the toggle flag bit (dq6) toggles until the erase cycle is complete. a 1 on the error flag bit (dq5) indicates a time-out condition on the erase cycle; a '0' indicates no error. the mcu can read any location within the sector being erased to get the toggle flag bit (dq6) and the error flag bit (dq5). psdsoft express generates ansi c code functions which implement these data toggling algorithms. figure 48. data toggle flowchart 21.7 erasing flash memory 21.7.1 flash bulk erase the flash bulk erase instruction uses six write operations followed by a read operation of the status register, as described in ta bl e 8 2 . if any byte of the bulk erase instruction is wrong, the bulk erase instruction aborts and the device is reset to the read flash memory status. during a bulk erase, the memory status may be checked by reading the error flag bit (dq5), the toggle flag bit (dq6), and the data polling flag bit (dq7), as detailed in section 21.6: programming flash memory . the error flag bit (dq5) returns a '1' if there has been an erase failure (maximum number of erase cycles have been executed). it is not necessary to program the memory with 00h because the psd module automatically does this before erasing to 0ffh. during execution of the bulk erase instruction, the flash memory does not accept any instructions. read dq5 & dq6 start read dq6 fail pass ai01370b dq6 = toggle no no yes yes dq5 = 1 no yes dq6 = toggle
upsd3212a, upsd3212c, upsd3212cv memory blocks 113/181 21.7.2 flash sector erase the sector erase instruction uses six write operations, as described in ta b l e 8 2 . additional flash sector erase codes and flash memory sector addresses can be written subsequently to erase other flash memory sectors in parallel, without further coded cycles, if the additional bytes are transmitted in a shorter time than the time-out period of about 100s. the input of a new sector erase code restarts the time-out period. the status of the internal timer can be monitored through the level of the erase time-out flag bit (dq3). if the erase time-out flag bit (dq3) is '0,' the sector erase instruction has been received and the time-out period is counting. if the erase time-out flag bit (dq3) is '1,' the time-out period has expired and the embedded algorithm is busy erasing the flash memory sector(s). before and during erase time-out, any instruction other than suspend sector erase and resume sector erase instructions abort the cycle that is currently in progress, and reset the device to read mode. during a sector erase, the memory status may be checked by reading the error flag bit (dq5), the toggle flag bit (dq6), and the data polling flag bit (dq7), as detailed in section 21.6: programming flash memory . during execution of the erase cycle, the fl ash memory accepts only reset and suspend sector erase instructions. erasure of one flash memory sector may be suspended, in order to read data from another flash memory sector, and then resumed. 21.7.3 suspend sector erase when a sector erase cycle is in progress, the suspend sector erase instruction can be used to suspend the cycle by writing 0b0h to any address when an appropriate sector select (fs0-fs3 or csboot 0-csboot1) is high. (see ta b l e 8 2 ). this allows reading of data from another flash memory sector after the erase cycle has been suspended. suspend sector erase is accepted only during an erase cycle and defaults to read mode. a suspend sector erase instruction executed during an erase time-out period, in addition to suspending the erase cycle, terminates the time out period. the toggle flag bit (dq6) stops toggling when the internal logic is suspended. the status of this bit must be monitored at an address within the flash memory sector being erased. the toggle flag bit (dq6) stops toggling between 0.1s and 15s after the suspend sector erase instruction has been executed. the flash memory is then automatically set to read mode. if an suspend sector erase instruction was executed, the following rules apply: attempting to read from a flash memory sector that was being erased outputs invalid data. reading from a flash sector that was not being erased is valid. the flash memory cannot be programmed, and only responds to resume sector erase and reset flash instructions (read is an operation and is allowed). if a reset flash instruction is received, data in the flash memory sector that was being erased is invalid. 21.7.4 resume sector erase if a suspend sector erase instruction was previously executed, the erase cycle may be resumed with this instruction. the resume sector erase instruction consists of writing 030h
memory blocks upsd3212a, upsd3212c, upsd3212cv 114/181 to any address while an appropriate sector select (fs0-fs3 or csboot0-csboot1) is high. (see ta b l e 8 2 .) 21.8 specific features 21.8.1 flash memory sector protect each primary and secondary flash memory sector can be separately protected against program and erase cycles. sector protection provides additional data security because it disables all program or erase cycles. this mo de can be activated through the jtag port or a device programmer. sector protection can be selected for each sector using the psdsoft express configuration program. this automatically protects selected sectors when the device is programmed through the jtag port or a device programmer. flash memory sectors can be unprotected to allow updating of their contents using the jtag port or a device programmer. the mcu can read (but cannot change) the sector protection bits. any attempt to program or erase a protected flash memory sector is ignored by the device. the verify operation results in a read of the protected data. this allows a guarantee of the retention of the protection status. the sector protection status can be read by the mcu through the flash memory protection registers (in the csiop block). see ta b l e 8 4 and ta b l e 8 5 . 1. bit definitions: sec_prot 1 = primary flash memory or secondar y flash memory sector is write-protected. sec_prot 0 = primary flash memo ry or secondary flash memory sect or is not write-protected. 1. bit definitions: sec_prot 1 = secondary flash memory sector is write-protected. sec_prot 0 = secondary flash memory sector is not write-protected. security_bit 0 = security bit in device has not been set; 1 = security bit in device has been set. 21.8.2 reset flash the reset flash instruction consists of one write cycle (see ta b l e 8 2 ). it can also be optionally preceded by the standard two write decoding cycles (writing aah to 555h and 55h to aaah). it must be executed after: reading the flash protection status or flash id an error condition has occurred (and the device has set the error flag bit (dq5) to '1' during a flash memory program or erase cycle. table 84. sector protection/security bit definition ? flash protection register bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 not used not used not used not used sec3_prot sec2_prot sec1_prot sec0_prot table 85. sector protection/security bit de finition ? secondary flash protection register bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 security_b it not used not used not used not used not used sec1_prot sec0_prot
upsd3212a, upsd3212c, upsd3212cv memory blocks 115/181 the reset flash instruction puts the flash memory back into normal read mode. if an error condition has occurred (and the device ha s set the error flag bit (dq5) to '1' the flash memory is put back into norm al read mode within a few milliseconds of the reset flash instruction having been issued. the reset flash instruction is ignored when it is issued during a program or bulk erase cycle of th e flash memory. the reset flash instruction aborts any on-going sector erase cycle, and re turns the flash memory to the normal read mode within a few milliseconds. 21.9 sram the sram is enabled when sram select (r s0) from the dpld is high. sram select (rs0) can contain up to two product terms, allowing flexible memory mapping. 21.10 sector select and sram select sector select (fs0-fs3, csboot0-csboot1) and sram select (rs0) are all outputs of the dpld. they are setup by writing equations for them in psdsoft express. the following rules apply to the equations for these signals: 1. primary flash memory and secondary flash memory sector select signals must not be larger than the physical sector size. 2. any primary flash memory sector must not be mapped in the same memory space as another flash memory sector. 3. a secondary flash memory sector must not be mapped in the same memory space as another secondary flash memory sector. 4. sram, i/o, and peripheral i/o spaces must not overlap. 5. a secondary flash memory sector may overlap a primary flash memory sector. in case of overlap, priority is given to the secondary flash memory sector. 6. sram, i/o, and peripheral i/o spaces may overlap any other memory sector. priority is given to the sram, i/o, or peripheral i/o. 21.10.1 example fs0 is valid when the address is in the range of 8000h to bfffh, csboot0 is valid from 8000h to 9fffh, and rs0 is valid from 8000h to 87ffh. any address in the range of rs0 always accesses the sram. any address in the range of csboot0 greater than 87ffh (and less than 9fffh) automatically addresses secondary flash memory segment 0. any address greater than 9fffh accesses the primary flash memory segment 0. you can see that half of the primary flash memory segment 0 and one-fourth of secondary flash memory segment 0 cannot be accessed in this example. note: an equation that defined fs1 to anywhere in the range of 8000h to bfffh would not be valid. figure 49 shows the priority levels for all memory components. any component on a higher level can overlap and has priority over any component on a lower level. components on the same level must not overlap. level one has the highest priority and level 3 has the lowest.
memory blocks upsd3212a, upsd3212c, upsd3212cv 116/181 21.10.2 memory select configur ation in program and data spaces the mcu core has separate address spaces for program memory and data memory. any of the memories within the psd module can reside in either space or both spaces. this is controlled through manipulation of the vm register that resides in the csiop space. the vm register is set using psdsoft express to have an initial value. it can subsequently be changed by the mcu so that memory mapping can be changed on-the-fly. for example, you may wish to have sram and primary flash memory in the data space at boot-up, and secondary flash memory in the program space at boot-up, and later swap the primary and secondary flash memories. this is easily done with the vm register by using psdsoft express configuration to configure it for boot-up and having the mcu change it when desired. ta b l e 8 6 describes the vm register. figure 49. priority level of memory and i/o components in the psd module 21.10.3 separate space mode program space is separated fr om data space. for example, program select enable (psen ) is used to access the program code from the primary flash memory, while read strobe (rd ) is used to access data from the secondary flash memory, sram and i/o port blocks. this configuration requires the vm register to be set to 0ch (see figure 50 ). table 86. vm register bit 7 pio_en bit 6 bit 5 bit 4 primary fl_data bit 3 secondary data bit 2 primary fl_cod e bit 1 secondary code bit 0 sram_co de 0 = disable pio mode not used not used 0 = rd can?t access flash memory 0 = rd can?t access secondary flash memory 0 = psen can?t access flash memory 0 = psen can?t access secondary flash memory 0 = psen can?t access sram 1= enable pio mode not used not used 1 = rd access flash memory 1 = rd access secondary flash memory 1 = psen access flash memory 1 = psen access secondary flash memory 1 = psen access sram level 1 sram, i /o, or peripheral i /o level 2 secondary non-volatile memory highest priority lowest priority level 3 primary flash memory ai02867d
upsd3212a, upsd3212c, upsd3212cv memory blocks 117/181 21.10.4 combined space modes the program and data spaces are combined into one memory space that allows the primary flash memory, secondary flash memory, and sram to be accessed by either program select enable (psen ) or read strobe (rd ). for example, to configure the primary flash memory in combined space, bits b2 and b4 of the vm register are set to '1' (see figure 51 ). 21.11 page register the 8-bit page register increases the addressing capability of the mcu core by a factor of up to 256. the contents of the register can also be read by the mcu. the outputs of the page register (pgr0-pgr7) are inputs to the dpld decoder and can be included in the sector select (fs0-fs7, csboot0-csboot 3), and sram select (rs0) equations. if memory paging is not needed, or if not all 8 page register bits are needed for memory paging, then these bits may be used in the cpld for general logic. figure 50. separate space mode figure 51. combined space mode primary flash memory dpld secondary flash memory sram rs0 csboot0-1 fs0-fs3 cs cs cs oe oe rd psen oe ai07433 primary flash memory dpld secondary flash memory sram rs0 csboot0-1 fs0-fs3 rd cs cs cs rd oe oe vm reg bit 2 psen vm reg bit 0 vm reg bit 1 vm reg bit 3 vm reg bit 4 oe ai07434
memory blocks upsd3212a, upsd3212c, upsd3212cv 118/181 figure 52 shows the page register. the eight flip-flops in the register are connected to the internal data bus d0-d7. the mcu can write to or read from the page register. the page register can be accessed at address location csiop + e0h. figure 52. page register reset d0-d7 r/w d0 q0 q1 q2 q3 q4 q5 q6 q7 d1 d2 d3 d4 d5 d6 d7 page register pgr0 pgr1 pgr2 pgr3 dpld and cpld internal psd module selects and logic pld pgr4 pgr5 pgr6 pgr7 ai05799
upsd3212a, upsd3212c, upsd3212cv plds 119/181 22 plds plds bring programmable logic functionality to the upsd. after specifying the logic for the plds using psdsoft express, the logic is programmed into the device and available upon power-up. note: 1. these inputs are not available in the 52-pin package. the psd module contains two plds: the decode pld (dpld), and the complex pld (cpld). the plds are briefly discussed in the next few paragraphs, and in more detail in section 22.2: decode pld (dpld) , and section 22.3: complex pld (cpld) . figure 53 shows the configuration of the plds. the dpld performs address decoding for select signals for psd module components, such as memory, registers, and i/o ports. the cpld can be used for logic functions, such as loadable counters and shift registers, state machines, and encoding and decoding logic. these logic functions can be constructed using the output macrocells (omc), input macr ocells (imc), and the and array. the cpld can also be used to generate external chip select (ecs1-ecs2) signals. the and array is used to form product term s. these product terms are specified using psdsoft. the pld input signals consist of internal mcu signals and external inputs from the i/o ports. the input signals are shown in ta b l e 8 7 . 22.1 turbo bit in psd module the plds can minimize power consumption by switching off when inputs remain unchanged for an extended time of about 70ns. resetting the turbo bit to '0' (bit 3 of pmmr0) automatically places the plds into standby if no inputs are changing. turning the turbo mode off increases propagation delays while reducing power consumption. table 87. dpld and cpld inputs input source input name number of signals mcu address bus a15-a0 16 mcu control signals psen , rd , wr , ale 4 reset rst 1 power-down pdn 1 port a input macrocells (1) pa 7 - pa 0 8 port b input macrocells pb7-pb0 8 port c input macrocells pc2-4, pc7 4 port d inputs pd2-pd1 2 page register pgr7-pgr0 8 macrocell ab feedback mcellab.fb7-fb0 8 macrocell bc feedback mcellbc.fb7-fb0 8 flash memory program status bit ready/busy 1
plds upsd3212a, upsd3212c, upsd3212cv 120/181 see section 24: power management for details on how to set the turbo bit. additionally, five bits are available in pmmr2 to block mcu control signals from entering the plds. this reduces power consumption and can be used only when these mcu control signals are not used in pld logic equations. each of the two plds has unique characteristics suited for its applications. they are described in the following sections. figure 53. pld diagram 1. port a is not available in the 52-pin package 22.2 decode pld (dpld) the dpld, shown in figure 88 , is used for decoding the address for psd module and external components. the dpld can be used to generate the following decode signals: 4 sector select (fs0-fs3) signals for the primary flash memory (three product terms each) 2 sector select (csboot0-csboot1) signals for the secondary flash memory (three product terms each) 1 internal sram select (rs0 ) signal (two product terms) 1 internal csiop select signal (selects the psd module registers) 2 internal peripheral select signals (peripheral i/o mode). pld input bus 8 input macrocell & input ports direct macrocell input to mcu data bus csiop select sram select secondary non-volatile memory selects decode pld page register peripheral selects cpld pt alloc. macrocell alloc. mcellab mcellbc direct macrocell access from mcu data bus 20 input macrocell (port a,b,c) 16 output macrocell i/o ports primary flash memory selects 2 port d inputs to port a or b 1 to port b or c data bus 8 8 8 4 1 1 2 external chip selects to port d 2 16 20 output macrocell feedback ai06600 73 73
upsd3212a, upsd3212c, upsd3212cv plds 121/181 1. port a inputs are not available in the 52-pin package 2. inputs from the mcu module 22.3 complex pld (cpld) the cpld can be used to implement system logic functions, such as loadable counters and shift registers, system mailboxes, handshaking protocols, state machines, and random logic. the cpld can also be used to generate external chip select (ecs1-ecs2), routed to port d. although external chip select (ecs1-ecs2) can be produced by any output macrocell (omc), these external chip select (ecs1-ecs2) on port d do not consume any output macrocells (omc). as shown in figure 54 , the cpld has the following blocks: 20 input macrocells (imc) 16 output macrocells (omc) macrocell allocator product term allocator and array capable of generating up to 137 product terms four i/o ports. each of the blocks are described in the sections that follow. table 88. dpld logic array (inputs) (20) (8) (16) (1) pdn (apd output) i /o ports (port a,b,c) 1 (8) pgr0 - pgr7 (8) mcellab.fb [7:0] (feedbacks) mcellbc.fb [7:0] (feedbacks) a [ 15:0 ] 2 (2) (4) pd [ 2:1 ] psen, rd, wr, ale 2 (1) (1) reset 2 rd_bsy rs0 csiop psel0 psel1 4 primary flash memory sector selects sram select i/o decoder select peripheral i/o mode select csboot 0 csboot 1 fs0 3 3 3 3 3 3 2 ai07436 fs1 fs2 fs3 1 1 1
plds upsd3212a, upsd3212c, upsd3212cv 122/181 the input macrocells (imc) and output macrocells (omc) are connected to the psd module internal data bus and can be directly accessed by the mcu. this enables the mcu software to load data into the output macrocells (omc) or read data from both the input and output macrocells (imc and omc). this feature allows efficient implementation of system logic and eliminates the need to connect the data bus to the and array as required in most standard pld macrocell architectures. figure 54. macrocell and i/o ports 22.4 output macrocell (omc) eight of the output macrocells (omc) are connected to ports a and b pins and are named as mcellab0-mcellab7. the other eight macroce lls are connected to ports b and c pins and are named as mcellbc0-mcellbc7. if an mcellab output is not assigned to a specific pin in psdsoft, the macrocell allocator block assigns it to either port a or b. the same is true for a mcellbc output on port b or c. ta b l e 8 9 shows the macrocells and port assignment. the output macrocell (omc) architecture is shown in figure 55 . as shown in the figure, there are native product terms available from the and array, and borrowed product terms available (if unused) from other output macrocells (omc). the polarity of the product term is controlled by the xor gate. the output macrocell (omc) can implement either sequential logic, using the flip-flop element, or combinatorial logic. the multiplexer selects between the sequential or combinatorial logic outputs. the multiplexer output can drive a port pin and has a feedback path to the and array inputs. the flip-flop in the output macrocell (omc) block can be configured as a d, t, jk, or sr type in psdsoft. the flip-flop?s clock, preset, and clear inputs may be driven from a product term of the and array. alternatively, clkin (pd1) can be used for the clock input to the flip- i/o ports cpld macrocells input macrocells latched address out mux mux mux mux mux d d q q q g d qd wr wr pdr data product term allocator dir reg. select input product terms from other macrocells polarity select up to 10 product terms clock select pr di ld d/t ck cl q d/t/jk ff select pt clear pt clock global clock pt output enable ( oe ) macrocell feedback i/o port input ale pt input latch gate/clock mcu load pt preset mcu data in comb. /reg select macrocell to i/o port alloc. cpld output to other i/o ports pld input bus pld input bus mcu address / data bus macrocell out to mcu data load control and array cpld output i/o pin ai06602
upsd3212a, upsd3212c, upsd3212cv plds 123/181 flop. the flip-flop is clocked on the rising edge of clkin (pd1). the preset and clear are active high inputs. each clear input can use up to two product terms. 1. mcellab0-mcellab7 can only be assig ned to port b in the 52-pin package 2. port pc0, pc1, pc5, and pc6 are assigned to jtag pins and are not available as macrocell outputs. 22.5 product term allocator the cpld has a product term allocator. psdsoft uses the product term allocator to borrow and place product terms from one macrocell to another. the following list summarizes how product terms are allocated: mcellab0-mcellab7 all have three native product terms and may borrow up to six more mcellbc0-mcellbc3 all have four native product terms and may borrow up to five more mcellbc4-mcellbc7 all have four native product terms and may borrow up to six more. each macrocell may only borrow product terms from certain other macrocells. product terms already in use by one macrocell are not available for another macrocell. if an equation requires more product terms than are available to it, then ?external? product terms are required, which consume other output macrocells (omc). if external product terms are used, extra delay is added for the equation that required the extra product terms. this is called product term expansion. psdsoft express performs this expansion as needed. table 89. output macrocell port and data bit assignments output macrocell port assignment (1,2) native product terms max. borrowed product terms data bit for loading or reading mcellab0 port a0, b0 3 6 d0 mcellab1 port a1, b1 3 6 d1 mcellab2 port a2, b2 3 6 d2 mcellab3 port a3, b3 3 6 d3 mcellab4 port a4, b4 3 6 d4 mcellab5 port a5, b5 3 6 d5 mcellab6 port a6, b6 3 6 d6 mcellab7 port a7, b7 3 6 d7 mcellbc0 port b0 4 5 d0 mcellbc1 port b1 4 5 d1 mcellbc2 port b2, c2 4 5 d2 mcellbc3 port b3, c3 4 5 d3 mcellbc4 port b4, c4 4 6 d4 mcellbc5 port b5 4 6 d5 mcellbc6 port b6 4 6 d6 mcellbc7 port b7, c7 4 6 d7
plds upsd3212a, upsd3212c, upsd3212cv 124/181 22.5.1 loading and reading the ou tput macrocells (omc) the output macrocells (omc) block occupies a memory location in the mcu address space, as defined by the csiop block (see section 23: i/o ports (psd module) ). the flip- flops in each of the 16 output macrocells (omc) can be loaded from the data bus by a mcu. loading the output macrocells (omc) with data from the mcu takes priority over internal functions. as such, the preset, clear, and clock inputs to the flip-flop can be overridden by the mcu. the ability to load the f lip-flops and read them bac k is useful in such applications as loadable counters and shift registers, mailboxes, and handshaking protocols. data can be loaded to the output macrocells (omc) on the trailing edge of write strobe (wr , edge loading) or during the time that write strobe (wr ) is active (level loading). the method of loading is specified in psdsoft express configuration. figure 55. cpld output macrocell 22.5.2 omc mask register there is one mask register for each of the tw o groups of eight output macrocells (omc). the mask registers can be used to block the loading of data to individual output macrocells (omc). the default value for the mask registers is 00h, which allows loading of the output macrocells (omc). when a given bit in a mask register is set to a '1,' the mcu is blocked from writing to the associated output macrocells (omc). for example, suppose mcellab0- mcellab3 are being used for a state machine. you would not want a mcu write to mcellab to overwrite the state machine registers. therefore, you would want to load the mask register for mcellab (mask macrocell ab) with the value 0fh. 22.5.3 output enab le of the omc the output macrocells (omc) block can be connected to an i/o port pin as a pld output. the output enable of each port pin driver is controlled by a single product term from the pt allocator mask reg. pt clk pt pt pt clkin feedback ( .fb ) port input and array pld input bus mux mux polarity select ld in clr q pr din comb/reg select port driver input macrocell i/o pin macrocell allocator mcu data bus d [ 7:0 ] direction register clear ( .re ) programmable ff ( d / t/jk /sr ) wr enable ( .oe ) preset ( .pr ) rd macrocell cs ai06617
upsd3212a, upsd3212c, upsd3212cv plds 125/181 and array, ored with the direction register output. the pin is enabled upon power-up if no output enable equation is defined and if the pin is declared as a pld output in psdsoft express. if the output macrocell (omc) output is declar ed as an internal node and not as a port pin output in the psdabel file, the port pin can be used for other i/o functions. the internal node feedback can be routed as an input to the and array. 22.6 input macrocells (imc) the cpld has 20 input macrocells (imc), one for each pin on ports a and b, and 4 on port c. the architecture of the input macrocells (imc) is shown in figure 56 . the input macrocells (imc) are individually configurable, and can be used as a latch, register, or to pass incoming port signals prior to driving them onto the pld input bus. the outputs of the input macrocells (imc) can be read by the mcu through the internal data bus. the enable for the latch and clock for the register are driven by a multiplexer whose inputs are a product term from the cpld and array or the mcu address strobe (ale). each product term output is used to latch or clock four input macrocells (imc). port inputs 3-0 can be controlled by one product term and 7-4 by another. configurations for the input macrocells (imc) are specified by equations written in psdsoft (see application note an1171 ). outputs of the input macrocells (imc) can be read by the mcu via the imc buffer. see section 23: i/o ports (psd module) . figure 56. input macrocell output macrocells bc and macrocell ab pt pt feedback and array pld input bus port driver i/o pin mcu data bus d [ 7: 0 ] direction register mux mux ale pt q q d d g latch input macrocell enable ( .oe ) d ff input macrocell _ rd ai06603
i/o ports (psd module) upsd 3212a, upsd3212c, upsd3212cv 126/181 23 i/o ports (psd module) there are four programmable i/o ports: ports a, b, c, and d in the psd module. each of the ports is eight bits except port d, which is 3 bits. each port pin is individually user configurable, thus allowing multiple functions per port. the ports are configured using psdsoft express configuration or by the mcu writing to on-chip registers in the csiop space. port a is not available in the 52-pin package. the topics discussed in this section are: general port architecture port operating modes port configuration registers (pcr) port data registers individual port functionality. 23.1 general port architecture the general architecture of the i/o port block is shown in figure 57 . individual port architectures are shown in figure 59 to figure 62 . in general, once the purpose for a port pin has been defined, that pin is no longer available for other purposes. exceptions are noted. as shown in figure 57 , the ports contain an output multiplexer whose select signals are driven by the configuration bits in the control registers (ports a and b only) and psdsoft express configuration. inputs to th e multiplexer include the following: output data from the data out register latched address outputs cpld macrocell output external chip select (ecs1-ecs2) from the cpld. the port data buffer (pdb) is a tri-state buffer that allows only one source at a time to be read. the port data buffer (pdb) is connected to the internal data bus for feedback and can be read by the mcu. the data out and macrocell outputs, direction and control registers, and port pin input are all connected to the port data buffer (pdb).
upsd3212a, upsd3212c, upsd 3212cv i/o ports (psd module) 127/181 figure 57. general i/o port architecture the port pin?s tri-state output driver enable is controlled by a two input or gate whose inputs come from the cpld and array enable product term and the direction register. if the enable product term of any of the array outputs are not defined and that port pin is not defined as a cpld output in the psdsoft, then the direction register has sole control of the buffer that drives the port pin. the contents of these registers can be alter ed by the mcu. the port data buffer (pdb) feedback path allows the mcu to check the contents of the registers. ports a, b, and c have embedded input macrocells (imc). the input macrocells (imc) can be configured as latches, registers, or direct inputs to the plds. the latches and registers are clocked by address strobe (ale) or a product term from the pld and array. the outputs from the input macrocells (imc) drive the pld input bus and can be read by the mcu. see figure 56 . 23.2 port operating modes the i/o ports have several modes of operation. some modes can be defined using psdsoft, some by the mcu writing to the control registers in csiop space, and some by both. the modes that can only be defined using psdsoft must be programmed into the device and cannot be changed unless the device is reprogrammed. the modes that can be changed by the mcu can be done so dynamically at run-time. the pld i/o, data port, address input, and peripheral i/o modes are the only modes that must be defined before programming the device. all other modes can be changed by the mcu at run-time. see application note an1171 for more detail. ta bl e 9 0 summarizes which modes are available on each port. ta bl e 9 3 shows how and where the different modes are configured. each of the port operating modes are described in the following sections. mcu data bus data out reg. dq d g q dq dq wr wr wr address macrocell outputs enable product term ( .oe ) ext cs ale read mux p d b cpld - input control reg. dir reg. input macrocell enable out data in output select output mux port pin data out address ai06604
i/o ports (psd module) upsd 3212a, upsd3212c, upsd3212cv 128/181 23.3 mcu i/o mode in the mcu i/o mode, the mcu uses the i/o ports block to expand its own i/o ports. by setting up the csiop space, the ports on the psd module are mapped into the mcu address space. the addresses of the ports are listed in ta b l e 8 1 . a port pin can be put into mcu i/o mode by writing a '0' to the corresponding bit in the control register. the mcu i/o direction may be changed by writing to the corresponding bit in the direction register, or by the output enable product term. see section 23.6: peripheral i/o mode . when the pin is configured as an output, the content of the data out register drives the pin. when configured as an input, the mcu can read the port input through the data in buffer. see figure 57 . ports c and d do not have control registers, and are in mcu i/o mode by default. they can be used for pld i/o if equations are written for them in psdabel. 23.4 pld i/o mode the pld i/o mode uses a port as an input to the cpld?s input macrocells (imc), and/or as an output from the cpld?s output macrocells (omc). the output can be tri-stated with a control signal. this output enable control signal can be defined by a product term from the pld, or by resetting the corresponding bit in the direction register to '0.' the corresponding bit in the direction register must not be set to '1' if the pin is defined for a pld input signal in psdsoft. the pld i/o mode is specified in psdsoft by declaring the port pins, and then writing an equation assigning the pld i/o to a port. 23.5 address out mode address out mode can be used to drive latc hed mcu addresses on to the port pins. these port pins can, in turn, drive external devices. either the output enable or the corresponding bits of both the direction register and control register must be set to a '1' for pins to use address out mode. this must be done by the mcu at run-time. see ta bl e 9 2 for the address output pin assignments on ports a and b for various mcus. 23.6 peripheral i/o mode peripheral i/o mode can be used to interface with external peripherals. in this mode, all of port a serves as a tri-state, bi-directional data buffer for the mcu. peripheral i/o mode is enabled by setting bit 7 of the vm register to a '1.' figure 58 shows how port a acts as a bi- directional buffer for the mcu data bus if peripheral i/o mode is enabled. an equation for psel0 and/or psel1 must be written in psdsoft . the buffer is tri-stated when psel0 or psel1 is low (not active). the psen signal should be ?anded? in the psel equations to disable the buffer when psel resides in the data space. 23.7 jtag in-system programming (isp) port c is jtag compliant, and can be used for in-system programming (isp). for more information on the jtag port, see section 26: programming in-circuit using the jtag serial interface .
upsd3212a, upsd3212c, upsd 3212cv i/o ports (psd module) 129/181 figure 58. peripheral i/o mode 1. port a is not available in the 52-pin package. 2. on pins pc2, pc3, pc4, and pc7 only. 3. jtag pins (tms, tck, tdi, tdo) are dedicated pins. 1. n/a = not applicable 2. the direction of the port a,b,c, and d pins are controlled by the directio n register ored with the individual output enable product term (.oe) from the cpld and array. table 90. port operating modes port mode port a (1) port b port c port d m c u i / o ye s ye s ye s ye s pld i/o mcellab outputs mcellbc outputs additional ext. cs outputs pld inputs ye s no no ye s ye s ye s no ye s no ye s (2) no ye s no no ye s ye s address out yes (a7 ? 0) yes (a7 ? 0) no no peripheral i/o yes no no no jtag isp no no yes (3) no table 91. port operating mode settings mode defined in psdsoft control register setting (1) direction register setting (1) vm register setting (1) mcu i/o declare pins only 0 1 = output, 0 = input (note 2) n/a pld i/o logic equations n/a (note 2) n/a address out (port a,b) declare pins only 1 1 (note 2) n/a peripheral i/o (port a) logic equations (psel0 & 1) n/a n/a pio bit = 1 table 92. i/o port latched address output assignments port a (pa3-pa0) port a (pa7-pa4) port b (pb3-pb0) port b (pb7-pb4) address a3-a0 address a7-a4 address a3-a0 address a7-a4 rd psel0 psel1 psel vm register bit 7 wr pa0-pa7 d0-d7 data bus ai02886
i/o ports (psd module) upsd 3212a, upsd3212c, upsd3212cv 130/181 23.8 port configuration registers (pcr) each port has a set of port configuration registers (pcr) used for configuration. the contents of the registers can be accessed by the mcu through normal read/write bus cycles at the addresses given in ta b l e 8 1 . the addresses in ta bl e 8 1 are the offsets in hexadecimal from the base of the csiop register. the pins of a port are individually configurable and each bit in the register controls its respective pin. for example, bit 0 in a register refers to bit 0 of its port. the three port configuration registers (pcr), shown in ta bl e 9 3 , are used for setting the port configurations. the default power-up state for each register in ta bl e 9 3 is 00h. 23.8.1 control register any bit reset to '0' in the control register sets the corresponding port pin to mcu i/o mode, and a '1' sets it to address out mode. the default mode is mcu i/o. only ports a and b have an associated control register. 23.8.2 direction register the direction register, in conjunction with the output enable (except for port d), controls the direction of data flow in the i/o ports. any bit set to '1' in the direction register causes the corresponding pin to be an output, and any bit set to '0' causes it to be an input. the default mode for all port pins is input. figure 59 and figure 60 show the port architecture diagrams for ports a/b and c, respectively. the direction of data flow for ports a, b, and c are controlled not only by the direction register, but also by the output enable product term from the pld and array. if the output enable product term is not active, the direction register has sole control of a given pin?s direction. an example of a configuration for a port with the three least significant bits set to output and the remainder set to input is shown in ta bl e 9 6 . since port d only contains two pins (shown in figure 62 ), the direction register for port d has only two bits active. 23.8.3 drive select register the drive select register configures the pin driver as open drain or cmos for some port pins, and controls the slew rate for the other port pins. an external pull-up resistor should be used for pins configured as open drain. a pin can be configured as open drain if its corresponding bit in the drive select register is set to a '1.' the default pin drive is cmos. note: the slew rate is a measurement of the rise and fall times of an output. a higher slew rate means a faster output response and may create more electrical noise. a pin operates in a high slew rate when the corresponding bit in the drive register is set to '1.' the default rate is slow slew. ta bl e 9 7 shows the drive register for ports a, b, c, and d. it summarizes which pins can be configured as open drain outputs and which pins the slew rate can be set for.
upsd3212a, upsd3212c, upsd 3212cv i/o ports (psd module) 131/181 note: 1. see table 97 for drive register bit definition. 23.9 port data registers the port data registers, shown in ta bl e 9 8 , are used by the mcu to write data to or read data from the ports. ta b l e 9 8 shows the register name, the ports having each register type, and mcu access for each register type. the registers are described below. 23.9.1 data in port pins are connected directly to the data in buffer. in mcu i/o input mode, the pin input is read through the data in buffer. 23.9.2 data out register stores output data written by the mcu in the mcu i/o output mode. the contents of the register are driven out to the pins if the direction register or the output enable product term is set to '1.' the contents of the register can also be read back by the mcu. 23.9.3 output macrocells (omc) the cpld output macrocells (omc) occupy a location in the mcu?s address space. the mcu can read the output of the output macrocells (omc). if the omc mask register bits table 93. port configuration registers (pcr) register name port mcu access control a,b write/read direction a,b,c,d write/read drive select (1) a,b,c,d write/read table 94. port pin direction control, output enable p.t. not defined direction register bit port pin mode 0 input 1 output table 95. port pin direction control, output enable p.t. defined direction register bit output enable p.t. port pin mode 0 0 input 0 1 output 1 0 output 1 1 output table 96. port direction assignment example bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 0 0 0 0 0 1 1 1
i/o ports (psd module) upsd 3212a, upsd3212c, upsd3212cv 132/181 are not set, writing to the macrocell loads data to the macrocell flip-flops. see section 22: plds . 23.9.4 omc mask register each omc mask register bit corresponds to an output macrocell (omc) flip-flop. when the omc mask register bit is set to a '1,' loading data into the output macrocell (omc) flip-flop is blocked. the default value is '0' or unblocked. 23.9.5 input macrocells (imc) the input macrocells (imc) can be used to latch or store external inputs. the outputs of the input macrocells (imc) are routed to the pld input bus, and can be read by the mcu. see section 22: plds . 23.9.6 enable out the enable out register can be read by the mcu. it contains the output enable values for a given port. a '1' indicates the driver is in output mode. a '0' indicates the driver is in tri-state and the pin is in input mode. 1. na = not applicable. table 97. drive register pin assignment drive register bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 port a open drain open drain open drain open drain slew rate slew rate slew rate slew rate port b open drain open drain open drain open drain slew rate slew rate slew rate slew rate port c open drain na (1) na (1) open drain open drain open drain na (1) na (1) port d na (1) na (1) na (1) na (1) na (1) slew rate slew rate na (1) table 98. port data registers register name port mcu access data in a,b,c,d read ? input on pin data out a,b,c,d write/read output macrocell a,b,c read ? outputs of macrocells write ? loading macrocells flip-flop mask macrocell a,b,c write/read ? prevents loading into a given macrocell input macrocell a,b,c read ? ou tputs of the input macrocells enable out a,b,c read ? the output enable control of the port driver
upsd3212a, upsd3212c, upsd 3212cv i/o ports (psd module) 133/181 23.10 ports a and b ? func tionality and structure ports a and b have similar functionality and structure, as shown in figure 59 . the two ports can be configured to perform one or more of the following functions: mcu i/o mode cpld output ? macrocells mc ellab7-mcellab0 can be connected to port a or port b. mcellbc7-mcellbc0 can be connected to port b or port c. cpld input ? via the input macrocells (imc). latched address output ? provide latched address output as per ta bl e 9 2 . open drain/slew rate ? pins pa3-pa0 and pb3-pb0 can be configured to fast slew rate, pins pa7-pa4 and pb7-pb4 can be configured to open drain mode. peripheral mode ? port a only (80-pin package) figure 59. port a and port b structure 23.11 port c ? functionality and structure port c can be configured to perform one or more of the following functions (see figure 60 ): mcu i/o mode cpld output ? mcellbc7-mcellbc0 outputs can be connected to port b or port c. cpld input ? via the input macrocells (imc) in-system programming (isp) ? jtag pins (tms, tck, tdi, tdo) are dedicated pins for device programming. (see section 26: programming in-circuit using the jtag serial interface , for more information on jtag programming.) open drain ? port c pins can be configured in open drain mode port c does not support address out mode, and therefore no control register is required. mcu data bus data out reg. dq d g q dq dq wr wr wr address macrocell outputs enable product term ( .oe ) ale read mux p d b cpld - input control reg. dir reg. input macrocell enable out data in output select output mux port a or b pin data out address a [ 7:0 ] ai06605
i/o ports (psd module) upsd 3212a, upsd3212c, upsd3212cv 134/181 figure 60. port c structure note: 1. isp 23.12 port d ? functionality and structure port d has two i/o pins (only one pin, pd1, in the 52-pin package). see figure 61 and figure 62 . this port does not support address out mode, and therefore no control register is required. of the eight bits in the port d registers, only bits 2 and 1 are used to configure pins pd2 and pd1. port d can be configured to perform one or more of the following functions: mcu i/o mode cpld output ? external chip select (ecs1-ecs2) cpld input ? direct input to the cpld, no input macrocells (imc) slew rate ? pins can be set up for fast slew rate port d pins can be configured in psdsoft express as input pins for other dedicated functions: clkin (pd1) as input to the macrocells flip-flops and apd counter psd chip select input (csi , pd2). driving this signal high disables the flash memory, sram and csiop. mcu data bus data out reg. dq dq wr wr mcellbc [ 7:0 ] enable product term ( .oe ) read mux p d b cpld - input dir reg. input macrocell enable out special function 1 special function 1 configuration bit data in output select output mux port c pin data out ai06618
upsd3212a, upsd3212c, upsd 3212cv i/o ports (psd module) 135/181 figure 61. port d structure 23.13 external chip select the cpld also provides two external chip select (ecs1-ecs2) outputs on port d pins that can be used to select external devices. each external chip select (ecs1-ecs2) consists of one product term that can be configured active high or low. the output enable of the pin is controlled by either the output enable product term or the direction register. (see figure 62 .) mcu data bus data out reg. dq dq wr wr ecs [ 2:1 ] read mux p d b cpld - input dir reg. data in enable product term (.oe) output select output mux port d pin data out ai06606
i/o ports (psd module) upsd 3212a, upsd3212c, upsd3212cv 136/181 figure 62. port d external chip select signals pld input bus polarity bit pd2 pin pt2 ecs2 direction register enable (.oe) polarity bit pd1 pin pt1 ecs1 enable (.oe) direction register cpld and array ai06607
upsd3212a, upsd3212c, up sd3212cv power management 137/181 24 power management all psd modules offer configurable power saving options. these options may be used individually or in combinations, as follows: the primary and secondary flash memory, and sram blocks are built with power management technology. in addition to usin g special silicon design methodology, power management technology puts the memories into standby mode when address/data inputs are not changing (zero dc current). as soon as a transition occurs on an input, the affected memory ?wakes up,? changes and latches its outputs, then goes back to standby. the designer does not have to do anything special to achieve memory standby mode when no inputs are changing?it happens automatically. the pld sections can also achieve standby mode when its inputs are not changing, as described in the sections on the power management mode registers (pmmr). as with the power management mode, the automatic power down (apd) block allows the psd module to reduce to standby current automatically. the apd unit can also block mcu address/data signals from reaching the memories and plds. built in logic monitors the address strobe of the mcu for activity. if there is no activity for a certain time period (mcu is asleep), the apd unit initiates power-down mode (if enabled). once in power-down mode, all address/data signals are blocked from reaching memory and plds, and the memories are deselected internally. this allows the memory and plds to remain in standby mode even if the address/data signals are changing state externally (noise, other devi ces on the mcu bus, etc.). keep in mind that any unblocked pld input signals that are changing states keeps the pld out of standby mode, but not the memories. psd chip select input (csi , pd2) can be used to disable the internal memories, placing them in standby mode even if inputs are changing. this feature does not block any internal signals or disable the plds. this is a good alternative to using the apd unit. there is a slight penalty in memory access time when psd chip select input (csi , pd2) makes its initial transition from deselected to selected. the pmmrs can be written by the mcu at run-time to manage power. the psd module supports ?blocking bits? in these registers that are set to block designated signals from reaching both plds. current consumption of the plds is directly related to the composite frequency of the changes on their inputs (see figure figure 66 and figure 67 ). significant power savings can be achieved by blocking signals that are not used in dpld or cpld logic equations.
power management upsd3212a, upsd3212c, upsd3212cv 138/181 figure 63. apd unit the psd module has a turbo bit in pmmr0. this bit can be set to turn the turbo mode off (the default is with turbo mode turned on). while turbo mode is off, the plds can achieve standby current when no pld inputs are changing (zero dc current). even when inputs do change, significant power can be saved at lower frequencies (ac current), compared to when turbo mode is on. when the turbo mode is on, there is a significant dc current component and the ac component is higher. automatic power-down (apd) unit and power-down mode the apd unit, shown in figure 63 , puts the psd module into power-down mode by monitoring the activity of address strobe (ale ). if the apd unit is enabled, as soon as activity on address strobe (ale) stops, a four-bit counter starts counting. if address strobe (ale/as, pd0) remains inactive for fifteen clock periods of clkin (pd1), power-down (pdn) goes high, and the psd module enters power-down mode, as discussed next. power-down mode by default, if you enable the apd unit, power-down mode is automatically enabled. the device enters power-down mode if address strobe (ale) remains inactive for fifteen periods of clkin (pd1). the following should be kept in mind when the psd module is in power-down mode: if address strobe (ale) starts pulsing again, the psd module returns to normal operating mode. the psd module also returns to normal operating mode if either psd chip select input (csi , pd2) is low or the reset input is high. the mcu address/data bus is blocked from all memory and plds. various signals can be blocked (prior to power-down mode) from entering the plds by setting the appropriate bits in the pmmr registers. the blocked signals include mcu control signals and the common clkin (pd1). note: blocking clkin (pd1) from the plds doe s not block clkin (pd1) from the apd unit. all memories enter standby mode and are drawing standby current. however, the pld and i/o ports blocks do not go into standby mode because you don?t want to have to wait for the logic and i/o to ?wake-up? before their outputs can change. see ta b l e 9 9 for power-down mode effects on psd module ports. typical standby current is of the order of microamperes. these standby current values assume that there are no transitions on any pld input. apd en pmmr0 bit 1=1 ale reset csi clkin transition detection edge detect apd counter power down ( pdn ) disable bus interface csiop select flash select sram select pd clr pd disable flash/sram pld select ai06608
upsd3212a, upsd3212c, up sd3212cv power management 139/181 other power-saving options the psd module offers other reduced power saving options that are independent of the power-down mode. except for th e psd chip select input (csi , pd2) features, they are enabled by setting bits in pmmr0 and pmmr2. figure 64. enable power-down flowchart 24.1 pld power management the power and speed of the plds are controlled by the turbo bit (bit 3) in pmmr0. by setting the bit to '1,' the turbo mode is off and the plds consume the specified standby current when the inputs are not switching for an extended time of 70 ns. the propagation delay time is increased by 10 ns (for a 5 v device) after the turbo bit is set to '1' (turned off) when the inputs change at a composite frequency of less than 15mhz. when the turbo bit is reset to '0' (turned on), the plds run at full power and speed. the turbo bit affects the pld?s dc power, ac power, and propagation delay. when the turbo mode is off, the upsd321xx devices? input clock frequency is reduced by 5 mhz from the maximum rated clock frequency. blocking mcu control signals with the bits of pmmr2 can further reduce pld ac power consumption. table 99. power-down mode?s effect on ports port function pin level mcu i/o no change pld out no change address out undefined peripheral i/o tri-state enable apd set pmmr0 bit 1 = 1 psd module in power down mode ale idle for 15 clkin clocks? reset yes no optional disable desired inputs to pld by setting pmmr0 bits 4 and 5 and pmmr2 bits 2 through 6. ai06609
power management upsd3212a, upsd3212c, upsd3212cv 140/181 24.2 psd chip select input (csi , pd2) pd2 of port d can be configured in psdsoft express as psd chip select input (csi ). when low, the signal selects and enables the psd module flash memory, sram, and i/o blocks for read or write operations. a high on psd chip select input (csi , pd2) disables the flash memory, and sram, and reduces power consumption. however, the pld and i/o signals remain operational when psd chip select input (csi , pd2) is high. 24.3 input clock clkin (pd1) can be turned off, to the pld to save ac power consumption. clkin (pd1) is an input to the pld and array and the output macrocells (omc). during power-down mode, or, if clkin (pd1) is not being used as part of the pld logic equation, the clock should be disabled to save ac power. clkin (pd1) is disconnected from the pld and array or the macrocells block by setting bits 4 or 5 to a '1' in pmmr0. 24.4 input control signals the psd module provides the option to turn off the mcu signals (wr , rd , psen , and address strobe (ale)) to the pld to save ac power consumption. these control signals are inputs to the pld and array. during power-down mode, or, if any of them are not being used as part of the pld logic equation, these control signals should be disabled to save ac power. they are disconnected from the pld and array by setting bits 2, 3, 4, 5, and 6 to a '1' in pmmr2. table 100. power management mode registers (pmmr0) bit 0 x 0 not used, and should be set to zero. bit 1 apd enable 0 = off automatic power-down (apd) is disabled. 1 = on automatic power-down (apd) is enabled. bit 2 x 0 not used, and should be set to zero. bit 3 pld turbo 0 = on pld turbo mode is on 1 = off pld turbo mode is off, saving power. upsd321xx devices operate at 5mhz below the maximum rated clock frequency bit 4 pld array clk 0 = on clkin (pd1) input to the pld and array is connected. every change of clkin (pd1) powers-up the pld when turbo bit is '0.' 1 = off clkin (pd1) input to pld and array is disconnected, saving power. bit 5 pld mcell clk 0 = on clkin (pd1) input to the pld macrocells is connected. 1 = off clkin (pd1) input to pld macrocells is disconnected, saving power. bit 6 x 0 not used, and should be set to zero. bit 7 x 0 not used, and should be set to zero.
upsd3212a, upsd3212c, up sd3212cv power management 141/181 1. the bits of this register are cleared to zero following power-up. subsequent reset pulses do not clear the registers. table 101. power management mode registers (pmmr2) bit 0 x 0 not used, and should be set to zero. bit 1 x 0 not used, and should be set to zero. bit 2 pld array wr 0 = on wr input to the pld and array is connected. 1 = off wr input to pld and array is disconnected, saving power. bit 3 pld array rd 0 = on rd input to the pld and array is connected. 1 = off rd input to pld and array is disconnected, saving power. bit 4 pld array psen 0 = on psen input to the pld and array is connected. 1 = off psen input to pld and array is disconnected, saving power. bit 5 pld array ale 0 = on ale input to the pld and array is connected. 1 = off ale input to pld and array is disconnected, saving power. bit 6 x 0 not used, and should be set to zero. bit 7 x 0 not used, and should be set to zero. table 102. apd counter operatio apd enable bit ale level apd counter 0 x not counting 1 pulsing not counting 1 0 or 1 counting (generates pdn after 15 clocks)
reset timing and device status at reset upsd3212a , upsd3212c, upsd3212cv 142/181 25 reset timing and device status at reset upon power-up, the psd module requires a reset (reset ) pulse of duration t nlnh-po after v cc is steady. during this period, the device loads internal configurations, clears some of the registers and sets the flash memory into operating mode. after the rising edge of reset (reset ), the psd module remains in the reset mode for an additional period, t opr , before the first memory access is allowed. the flash memory is reset to the read mode upon power-up. sector select (fs0-fs3 and csboot0-csboot1) must all be low, write strobe (wr , cntl0) high, during power- on reset for maximum security of the data contents and to remove the possibility of a byte being written on the first edge of write strobe (wr ). any flash memory write cycle initiation is prevente d automatically when v cc is below v lko . 25.1 warm reset once the device is up and running, the psd module can be reset with a pulse of a much shorter duration, t nlnh . the same t opr period is needed before the device is operational after a warm reset . figure 65 shows the timing of the power-up and warm reset . 25.2 i/o pin, register and pld status at reset table 103 shows the i/o pin, register and pld status during power-on reset , warm reset , and power-down mode. pld outputs are always valid during warm reset , and they are valid in power-on reset once the internal configuration bits are loaded. this loading is completed typi cally long before the v cc ramps up to operating level. once the pld is active, the state of the outputs are determined by the pld equations. figure 65. reset (reset ) timing t nlnh-po t opr ai02866b reset t nlnh t nlnh-a t opr v cc v cc (min) power-on reset warm reset
upsd3212a, upsd3212c, upsd3212cv reset timing and device status at reset 143/181 1. the sr_cod and periphmode bits in the vm regi ster are always cleared to '0' on power-on reset or warm reset . table 103. status during power-on reset , warm reset and power-down mode port configuration power-on reset warm reset power-down mode mcu i/o input mode input mode unchanged pld output valid after internal psd configuration bits are loaded valid depends on inputs to pld (addresses are blocked in pd mode) address out tri-stated tri-stated not defined peripheral i/o tri-stated tri-stated tri-stated register power-on reset warm reset power-down mode pmmr0 and pmmr2 cleared to '0' unchanged unchanged macrocells flip-flop status cleared to '0' by internal power-on reset depends on .re and .pr equations depends on .re and .pr equations vm register (1) initialized, based on the selection in psdsoft configuration menu initialized, based on the selection in psdsoft configuration menu unchanged all other registers cleared to '0' cleared to '0' unchanged
programming in-circuit using the jtag serial interface upsd3212a, upsd3212c, upsd3212cv 144/181 26 programming in-circuit using the jtag serial interface the jtag serial interface pins (tms, tck, tdi, and tdo) are dedicated pins on port c (see table 104 ). all memory blocks (primary and secondary flash memory), pld logic, and psd module configuration register bits may be programmed through the jtag serial interface block. a blank device can be mounted on a printed circuit board and programmed using jtag. the standard jtag signals (ieee 1149.1) are tms, tck, tdi, and tdo. two additional signals, tstat and terr , are optional jtag extensions used to speed up program and erase cycles. by default, on a blank device (as shipped from the factory or after erasure), four pins on port c are the basic jtag signals tms, tck, tdi, and tdo . 26.1 standard jtag signals at power-up, the standard jtag pins are inputs, waiting for a jtag serial command from an external jtag controller device (such as flashlink or automated test equipment). when the enabling command is received, tdo becomes an output and the jtag channel is fully functional. the same command that enables the jtag channel may optionally enable the two additional jtag signals, tstat and terr . the reset input to the ups3200 should be active during jtag programming. the active reset puts the mcu module into reset mode while the psd module is being programmed. see application note an1153 for more details on jtag in-system programming (isp). upsd321xx devices support jtag in-system-configuration (isc) commands, but not boundary scan. the psdsoft express softwar e tool and flashlink jtag programming cable implement the jtag in-system-configuration (isc) commands. 26.2 jtag extensions tstat and terr are two jtag extension signals enabled by an ?isc_enable? command received over the four standard jtag signals (tms, tck, tdi, and tdo). they are used to speed program and erase cycles by indicating st atus on upds signals instead of having to table 104. jtag port signals port c pin jtag signals description pc0 tms mode select pc1 tck clock pc3 tstat status (optional) pc4 terr error flag (optional) pc5 tdi serial data in pc6 tdo serial data out
upsd3212a, upsd3212c, upsd3212cv programming in-circuit using the jtag serial interface 145/181 scan the status out serially using the standard jtag channel. see application note an1153 . terr indicates if an error has occurred when erasing a sector or programming a byte in flash memory. this signal goes low (active) when an error condition occurs, and stays low until an ?isc_clear? command is executed or a chip reset (reset ) pulse is received after an ?isc_disable? command. tstat behaves the same as ready/busy described in section 21.2.1: ready/busy (pc3) . tstat is high when the psd module device is in read mode (primary and secondary flash memory contents can be read). tstat is low when flash memory program or erase cycles are in progress, and also when data is being written to the secondary flash memory. tstat and terr can be configured as open-drain type signals during an ?isc_enable? command. 26.3 security and fl ash memory protection when the security bit is set, the device cannot be read on a device programmer or through the jtag port. when using the jtag port, only a full chip erase command is allowed. all other program, erase and verify commands are blocked. full chip erase returns the part to a non-secured blank state. the security bit can be set in psdsoft express configuration. all primary and secondary flash memory sectors can individually be sector protected against erasures. the sector protect bits can be set in psdsoft express configuration.
initial delivery state upsd3212a, upsd3212c, upsd3212cv 146/181 27 initial delivery state when delivered from st, the upsd321xx devices have all bits in the memory and plds set to '1.' the code, configuration, and pld logic are loaded using the programming procedure. information for programming the device is available directly from st. please contact your local sales representative.
upsd3212a, upsd3212c, up sd3212cv ac/dc parameters 147/181 28 ac/dc parameters these tables describe the ad and dc parameters of the upsd321xx devices: dc electrical specification ac timing specification pld timing ? combinatorial timing ? synchronous clock mode ? asynchronous clock mode ? input macrocell timing mcu module timing ? read timing ? write timing ? power-down and reset timing the following are issues concerning the parameters presented: in the dc specification the supply current is given for different modes of operation. the ac power component gives the pld, flash memory, and sram ma/mhz specification. figure 66 and figure 67 show the pld ma/mhz as a function of the number of product terms (pt) used. in the pld timing parameters, add the required delay when turbo bit is '0.' figure 66. pld i cc /frequency consumption (5 v range) 0 10 20 30 40 60 70 80 90 100 110 v cc = 5v 50 01015 5 20 25 highest composite frequency at pld inputs (mhz) i cc ? (ma) turbo on (100%) turbo on (25%) turbo off turbo off pt 100% pt 25% ai02894
ac/dc parameters upsd3212a, upsd3212c, upsd3212cv 148/181 figure 67. pld i cc /frequency consumption (3 v range) table 105. psd module example, typ. power calculation at v cc = 5.0 v (turbo mode off) conditions mcu clock frequency = 12 mhz highest composite pld input frequency (freq pld) = 8 mhz mcu ale frequency (freq ale) = 2 mhz % flash memory access = 80% % sram access = 15% % i/o access = 5% (no additional power above base) operational modes % normal = 40% % power-down mode = 60% number of product terms used (from fitter report) = 45 pt % of total product terms = 45/182 = 24.7% turbo mode = off 0 10 20 30 40 50 60 v cc = 3v 01015 5 20 25 i cc ? (ma) turbo on (100%) turbo on (25%) turbo off turbo off highest composite frequency at pld inputs (mhz) pt 100% pt 25% ai03100
upsd3212a, upsd3212c, up sd3212cv ac/dc parameters 149/181 calculation (using typical values) i cc total = i cc (mcuactive) x %mcuactive + i cc (psdactive) x %psdactive + i pd (pwrdown) x %pwrdown i cc (mcuactive) = 20ma i pd (pwrdown) = 250a i cc (psdactive) = i cc (ac) + i cc (dc) = %flash x 2.5ma/ mhz x freq ale + %sram x 1.5ma/mhz x freq ale + % pld x (from graph using freq pld) = 0.8 x 2.5ma/mhz x 2mhz + 0.15 x 1.5ma/mhz x 2mhz + 24ma = (4 + 0.45 + 24) ma = 28.45ma i cc total = 20ma x 40% + 28.45ma x 40% + 250a x 60% = 8ma + 11.38ma + 150a = 19.53ma this is the operating power with no flash memory erase or program cycles in progress. calculation is based on all i/o pins being disconnected and i out = 0ma. table 105. psd module example, typ. power calculation at v cc = 5.0 v (turbo mode off) (continued) conditions
maximum ratings upsd3212a, upsd3212c, upsd3212cv 150/181 29 maximum ratings stressing the device above the rating listed in the absolute maximum ratings? table may cause permanent damage to the device. these are stress ratings only and operation of the device at these or any other conditions above those indicated in the operating sections of this specification is not implied. exposure to absolute maximum rating conditions for extended periods may affect device reliability. refer also to the stmicroelectronics sure program and other relevant quality documents. 1. ipc/jedec j-std-020a 2. jedec std jesd22-a114a (c1=100pf, r1=1500 , r2=500 ) table 106. absolute maximum ratings symbol parameter min. max. unit t stg storage temperature ?65 125 c t lead lead temperature during soldering (20 seconds max.) (1) 235 c v io input and output voltage (q = v oh or hi-z) ?0.5 6.5 v v cc supply voltage ?0.5 6.5 v v pp device programmer supply voltage ?0.5 14.0 v v esd electrostatic discharge voltage (human body model) 2 ?2000 2000 v
upsd3212a, upsd3212c, upsd 3212cv emc characteristics 151/181 30 emc characteristics susceptibility test ar e performed on a sample basis during product characterization. 30.1 functional ems (electromagnetic susceptibility) based on a simple running application on the product (toggling 2 leds through i/o ports), the product is stressed by two electromagnetic ev ents until a failure occurs (indicated by the leds). 30.1.1 esd electro-static discharge (positive and negative) is applied on all pins of the device until a functional disturbance occurs. this test conforms with the iec 1000-4-2 standard. 30.1.2 ftb a burst of fast transient voltage (positive and negative) is applied to v dd and v ss through a 100pf capacitor, until a functional disturbance occurs. this test conforms with the iec 1000-4-2 standard. a device reset allows normal operations to be resumed. the test results are given in table 107 , based on the ems levels and classes defined in applicat ion note an1709. 30.2 designing hardened soft ware to avoid noise problems emc characterization and optimization are performed at component level with a typical application environment and simplified mcu software. it should be noted that good emc performance is highly dependent on the user application and the software in particular. therefore, it is recommended that the user applies emc software optimization and prequalification tests in relation with the emc level requested for the user?s application. 30.2.1 software recommendations the software flowchart must include the management of ?runaway? conditions, such as: corrupted program counter unexpected reset critical data corruption (e.g., control registers) 30.2.2 prequalification trials most of the common failures (unexpected reset and program counter corruption) can be reproduced by manually forci ng a low state on the reset pin or the oscillator pins for 1 second. to complete these trials, esd stress can be applied directly on the device over the range of specification values. when unexpected behavior is detected, the software can be hardened to prevent unrecoverable errors occurring (see application note an1015).
emc characteristics upsd3212a, upsd3212c, upsd3212cv 152/181 30.3 absolute maximum rati ngs (electrical sensitivity) based on three different tests (esd, lu, and dlu) and using specific measurement methods, the product is stressed in order to determine its performance in terms of electrical sensitivity. for more details, refe r to the application note an1181. 30.3.1 electro-static discharge (esd) electro-static discharges (a positive then a negative pulse separated by 1 second) are applied to the pins of each sample according to each pin combination. the sample size depends on the number of supply pins in the device (3 parts*(n+1) supply pin). the human body model is simulated ( ta bl e 1 0 8 ). this test complies with the jesd22-a114a standard. 1. data based on characterization results, not tested in production. 1. data based on characterization results, not tested in production 30.3.2 latch-up 3 complementary static tests are required on 10 parts to assess the latch-up performance. a supply overvoltage (applied to each power supply pin) and a current injection (applied to each input, output, and configurable i/o pin) are performed on each sample. this test conforms to the eia/jesd 78 ic latch-up standard (see ta b l e 1 0 9 ). for more details, refer to the application note, an1181. 30.3.3 dynamic latch-up electro-static discharges (one positive then one negative test) are applied to each pin of 3 samples when the micro is running to assess the latch-up performance in dynamic mode. power supplies are set to the typical values, th e oscillator is connecte d as near as possible to the pins of the micro, and the component is put in reset mode. this test conforms to the iec 1000-4-2 and saej17 52/3 standards (see ta bl e 1 0 9 ). for more details, refer to the application note, an1181. 1. class description: a class is an stmi croelectronics internal spec ification. all of its limits are higher than the jedec specifications. this means when a device belongs to ?class a,? it exceeds the jedec standard. ?class b? strictly covers all of the jedec criteria (int ernational standards). table 107. ems test results symbol parameter conditions level/class (1) v fesd voltage limits to be applied on any i/o pin to induce a functional disturbance v dd = 4v; t a = 25c; f osc = 40mhz; wdt off complies with iec 1000-4-2 3c table 108. esd absolute maximum ratings symbol parameter conditions max. value (1) unit v esd(hbm) electro-static discharge voltage (human body model) t a = 25c 2000 v table 109. latch-up and dynamic latch-up electrical sensitivities symbol parameter conditions level/class (1) lu static latch-up class t a = 25c a dlu dynamic latch-up class v dd = 5 v; t a = 25c; f osc = 40 mhz a
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 153/181 31 dc and ac parameters this section summarizes the operating and measurement conditions, and the dc and ac characteristics of the device. the parameters in the dc and ac characteristic tables that follow are derived from tests performed under the measurement conditions summarized in the relevant tables. designers should check that the operating conditions in their circuit match the measurement conditions when relying on the quoted parameters. 1. example: t avlx = time from address valid to ale invalid. table 110. operating conditions (5 v devices) symbol parameter min. max. unit v cc supply voltage 4.5 5.5 v t a ambient operating temperature (industrial) ?40 85 c ambient operating temperature (commercial) 0 70 c table 111. operating conditions (3 v devices) symbol parameter min. max. unit v cc supply voltage 3.0 3.6 v t a ambient operating temperature (industrial) ?40 85 c ambient operating temperature (commercial) 0 70 c table 112. ac signal letters for timing aaddress c clock d input data i instruction lale n reset input or output p psen signal q output data r rd signal w wr signal m output macrocell
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 154/181 1. example: t avlx = time from address valid to ale invalid. figure 68. switching waveforms ? key table 113. ac signal behavior symbols for timing ttime l logic level low or ale h logic level high v valid x no longer a valid logic level z float pw pulse width table 114. major parameters parameters/conditions/ comments 5 v test conditions 5.0 v value 3.3 v test conditions 3.3 v value unit operating voltage ? 4.5 to 5.5 ? 3.0 to 3.6 v operating temperature ? ?40 to 85 ? ?40 to 85 c mcu frequency 12 mhz (min) for usb; 8 mhz (min) for i 2 c ? 1 min, 40 max ? 1 min, 24 max mhz active current, typical (25c operation; 80% flash and 15% sram accesses, 45 pld product terms used; pld turbo mode off) 24 mhz mcu clock, 12 mhz pld input frequency, 4 mhz ale 72 12 mhz mcu clock, 6 mhz pld input frequency, 2mhz ale 21 ma idle current, typical (cpu halted but some peripherals active; 25c operation; 45 pld product terms used; pld turbo mode off) 24 mhz mcu clock, 12 mhz pld input frequency 25 12 mhz mcu clock, 1 mhz pld input frequency 7ma waveforms inputs outputs steady input may change from hi to lo may change from lo to hi don't care outputs only steady output will be changing from hi to lo will be changing lo to hi changing, state unknown center line is tri-state ai03102
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 155/181 standby current, typical (power-down mode, requires reset to exit mode; without low-voltage detect (lvd) supervisor) 180 a with lvd 110 100 a with lvd 60 a i/o sink/source current ports a, b, c, and d v ol = 0.25 v (max); v oh = 3.9 v (min) i ol = 8 (max); i oh = ?2 (min) v ol = 0.15 v (max); v oh = 2.6 v (min) i ol = 4 (max); i oh = ?1 (min) ma pld macrocells (for registered or combinatorial logic) ?16?16? pld inputs (inputs from pins, macrocell feedback, or mcu addresses) ?69?69? pld outputs (output to pins or internal feedback) ?16?16? pld propagation delay, typical (pld input to output, turbo mode) ? 15 ? 22 ns table 114. major parameters (continued) parameters/conditions/ comments 5 v test conditions 5.0 v value 3.3 v test conditions 3.3 v value unit
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 156/181 table 115. dc characteristics (5 v devices) symbol parameter test conditions (in addition to those in table 110 ) min. typ. max. unit v ih input high voltage (ports 1, 2, 3, 4[bits 7,6,5,4,3,1,0], xtal1, reset ) 4.5 v < v cc < 5.5 v 0.7 v cc v cc + 0.5 v v ih1 input high voltage (ports a, b, c, d, 4[bit 2], usb+, usb?) 4.5 v < v cc < 5.5 v 2.0 v cc + 0.5 v v il input low voltage (ports 1, 2, 3, 4[bits 7,6,5,4,3,1,0], xtal1, reset ) 4.5 v < v cc < 5.5 v v ss ?0.5 0.3 v c c v v il1 input low voltage (ports a, b, c, d, 4[bit 2]) 4.5 v < v cc < 5.5 v ?0.5 0.8 v input low voltage (usb+, usb?) 4.5 v < v cc < 5.5 v v ss ?0.5 0.8 v v ol output low voltage (ports a,b,c,d) i ol = 20 a v cc = 4.5 v 0.01 0.1 v i ol = 8 ma v cc = 4.5 v 0.25 0.45 v v ol1 output low voltage (ports 1,2,3,4, wr , rd ) i ol = 1.6 ma 0.45 v v ol2 output low voltage (port 0, ale, psen) i ol = 3.2 ma 0.45 v v oh output high voltage (ports a,b,c,d) i oh = ?20 a v cc = 4.5 v 4.4 4.49 v i oh = ?2 ma v cc = 4.5 v 2.4 3.9 v v oh2 output high voltage (port 0 in ext. bus mode, ale, psen) i oh = ?800 a 2.4 v i oh = ?80 a 4.05 v v lv r low voltage reset 0.1 v hysteresis 3.75 4.0 4.25 v v op xtal open bias voltage (xtal1, xtal2) i ol = 3.2 ma 2.0 3.0 v v lko v cc (min) for flash erase and program 2.5 4.2 v i il logic '0' input current (ports 1,2,3,4) v in = 0.45 v (0 v for port 4[pin 2]) ?10 ?50 a i tl logic 1-to-0 transition current (ports 1,2,3,4) v in = 3.5 v (2.5 v for port 4[pin 2]) ?65 ?650 a i rst reset pin pull-up current (reset ) v in = v ss ?10 ?55 a
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 157/181 1. i pd (power-down mode) is measured with: xtal1=v ss ; xtal2=not connected; reset =v cc ; port 0 =v cc ; all other pins are disconnected. pld not in turbo mode. 2. i cc_cpu (active mode) is measured with: xtal1 driven with t clch , t chcl = 5 ns, v il = v ss +0.5 v, v ih = vcc ? 0.5 v, xtal2 = not connected; reset =v ss ; port 0=v cc ; all other pins are disconnected. i cc would be slightly higher if a crystal oscillator is used (approximately 1ma). 3. i cc_cpu (idle mode) is measured with: xtal1 driven with t clch , t chcl = 5 ns, v il = v ss +0.5 v, v ih = v cc ? 0.5 v, xtal2 = not connected; port 0 = v cc ; 4. reset =v cc ; all other pins are disconnected. 5. pld is in non-turbo mode and none of the inputs are switching. 6. see figure 66 for the pld current calculation. 7. i/o current = 0 ma, all i/o pins are disconnected. i fr xtal feedback resistor current (xtal1) xtal1 = v cc xtal2 = v ss ?20 ?50 a i li input leakage current v ss < v in < v cc ?1 1 a i lo output leakage current 0.45 < v out < v cc ?10 10 a i pd (1) power-down mode v cc = 5.5 v lvd logic disabled 250 a lvd logic enabled 380 a i cc_cpu (2,3,6) active (12 mhz) v cc = 5 v 20 30 ma idle (12 mhz) 8 10 ma active (24 mhz) v cc = 5 v 30 38 ma idle (24 mhz) 15 20 ma active (40 mhz) v cc = 5 v 40 62 ma idle (40 mhz) 20 30 ma i cc_psd (dc) (6) operating supply current pld only pld_turbo = off, f = 0 mhz (4) 0 a/pt (5) pld_turbo = on, f = 0 mhz 400 700 a/pt flash memory during flash memory write/erase only 15 30 ma read-only, f = 0 mhz 0 0 ma sram f = 0 mhz 0 0 ma i cc_psd (ac) (6) pld ac base note 5 flash memory ac adder 2.5 3.5 ma/mhz sram ac adder 1.5 3.0 ma/mhz table 115. dc characteristics (5 v devices) (continued) symbol parameter test conditions (in addition to those in table 110 ) min. typ. max. unit
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 158/181 table 116. dc characteristics (3 v devices) symbol parameter test conditions (in addition to those in table 111 ) min. typ. max. unit v ih input high voltage (ports 1, 2, 3, 4[bits 7, 6,5,4,3,1,0], a, b, c, d, xtal1, reset ) 3.0 v < v cc < 3.6 v 0.7v cc v cc + 0.5 v v ih1 input high voltage (port 4[bit 2]) 3.0 v < v cc < 3.6 v 2.0 v cc + 0.5 v v il input high voltage (ports 1, 2, 3, 4[bits 7,6,5,4,3,1,0], xtal1, reset ) 3.0 v < v cc < 3.6 v v ss ?0.5 0.3 v cc v v il1 input low voltage (ports a, b, c, d) 3.0 v < v cc < 3.6 v ?0.5 0.8 v input low voltage (port 4[bit 2]) 3.0 v < v cc < 3.6 v v ss ?0.5 0.8 v v ol output low voltage (ports a,b,c,d) i ol = 20 a v cc = 3.0 v 0.01 0.1 v i ol = 4 ma v cc = 3.0 v 0.15 0.45 v v ol1 output low voltage (ports 1,2,3,4, wr , rd ) i ol = 1.6 ma 0.45 v i ol = 100 a 0.3 v v ol2 output low voltage (port 0, ale, psen) i ol = 3.2 ma 0.45 v i ol = 200 a 0.3 v v oh output high voltage (ports a,b,c,d) i oh = ?20 a v cc = 3.0 v 2.9 2.99 v i oh = ?1 ma v cc = 3.0 v 2.4 2.6 v v oh2 output high voltage (port 0 in ext. bus mode, ale, psen ) i oh = ?800 a 2.0 v i oh = ?80 a 2.7 v v lv r low voltage reset 0.1 v hysteresis 2.3 2.5 2.7 v v op xtal open bias voltage (xtal1, xtal2) i ol = 3.2 ma 1.0 2.0 v v lko v cc (min) for flash erase and program 1.5 2.2 v i il logic '0' input current (ports 1,2,3,4) v in = 0.45 v (0 v for port 4[pin 2]) ?1 ?50 a i tl logic 1-to-0 transition current (ports 1,2,3,4) v in = 3.5 v (2.5 v for port 4[pin 2]) ?25 ?250 a i rst reset pin pull-up current (reset ) v in = v ss ?10 ?55 a i fr xtal feedback resistor current (xtal1) xtal1 = v cc xtal2 = v ss ?20 ?50 a i li input leakage current v ss < v in < v cc ?1 1 a i lo output leakage current 0.45 < v out < v cc ?10 10 a
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 159/181 1. i pd (power-down mode) is measured with: xtal1=v ss ; xtal2=not connected; reset =v cc ; port 0 =v cc ; all other pins are disconnected. pld not in turbo mode. 2. i cc_cpu (active mode) is measured with: xtal1 driven with t clch , t chcl = 5 ns, v il = v ss +0.5 v, v ih = vcc ? 0.5 v, xtal2 = not connected; reset =v ss ; port 0=v cc ; all other pins are disconnected. i cc would be slightly higher if a crystal oscillator is used (approximately 1 ma). 3. i cc_cpu (idle mode) is measured with: xtal1 driven with t clch , t chcl = 5 ns, v il = v ss +0.5 v, v ih = v cc ? 0.5 v, xtal2 = not connected; port 0 = v cc ; 4. reset = v cc ; all other pins are disconnected. 5. pld is in non-turbo mode and none of the inputs are switching. 6. see figure 66 for the pld current calculation. 7. i/o current = 0 ma, all i/o pins are disconnected. i pd (1) power-down mode v cc = 3.6 v lvd logic disabled 110 a lvd logic enabled 180 a i cc_cpu (2,3,6) active (12 mhz) v cc = 3.6 v 810 ma idle (12 mhz) 4 5 ma active (24 mhz) v cc = 3.6 v 15 20 ma idle (24 mhz) 8 10 ma i cc_psd (dc) (6) operating supply current pld only pld_turbo = off, f = 0 mhz (4) 0 a/pt (5) pld_turbo = on, f = 0 mhz 200 400 a/pt flash memory during flash memory write/erase only 10 25 ma read-only, f = 0 mhz 0 0 ma sram f = 0 mhz 0 0 ma i cc_psd (ac) (6) pld ac base note 5 flash memory ac adder 1.5 2.0 ma/mhz sram ac adder 0.8 1.5 ma/mhz table 116. dc characteristics (3 v devices) (continued) symbol parameter test conditions (in addition to those in table 111 ) min. typ. max. unit
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 160/181 figure 69. external program memory read cycle 1. conditions (in addition to those in table 110 , v cc = 4.5 to 5.5 v): v ss = 0 v; c l for port 0, ale and psen output is 100 pf; c l for other outputs is 80 pf 2. interfacing the upsd321xx devices to devices with float times up to 20 ns is permissible. this limited bus contention does not cause any damage to port 0 drivers. table 117. external program memory ac characteristics (with the 5 v mcu module) symbol parameter (1) 40 mhz oscillator variable oscillator 1/t clcl = 24 to 40 mhz unit min. max. min. max. t lhll ale pulse width 35 2 t clcl ? 15 ns t avll address set-up to ale 10 t clcl ? 15 ns t llax address hold after ale 10 t clcl ? 15 ns t lliv ale low to valid instruction in 55 4 t clcl ? 45 ns t llpl ale to psen 10 t clcl ? 15 ns t plph psen pulse width 60 3 t clcl ? 15 ns t pliv psen to valid instruction in 30 3 t clcl ? 45 ns t pxix input instruction hold after psen 00 ns t pxiz (2) input instruction float after psen 15 t clcl ? 10 ns t pxav (2) address valid after psen 20 t clcl ? 5 ns t aviv address to valid instruction in 70 5 t clcl ? 55 ns t azpl address float to psen ?5 ?5 ns t avll t plph t pxiz t aviv psen port 2 port 0 ai06848 t lhll ale t llpl a0-a7 t llax t azpl t lliv t pliv a0-a7 t pxav t pxix a8-a11 instr in a8-a11
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 161/181 1. conditions (in addition to those in table 111 , v cc = 3.0 to 3.6 v): v ss = 0 v; c l for port 0, ale and psen output is 100 pf, for 5 v devices, and 50 pf for 3 v devices; c l for other outputs is 80 pf, for 5 v devices, and 50 pf for 3 v devices) 2. interfacing the upsd321xx devices to devices with float times up to 35 ns is permissible. this limited bus contention does not cause any damage to port 0 drivers. 1. conditions (in addition to those in table 110 , v cc = 4.5 to 5.5 v): v ss = 0 v; c l for port 0, ale and psen output is 100 pf; c l for other outputs is 80 pf table 118. external program memory ac characteristics (with the 3 v mcu module) symbol parameter (1) 24 mhz oscillator variable oscillator 1/t clcl = 8 to 24 mhz unit min. max. min. max. t lhll ale pulse width 43 2 t clcl ? 40 ns t avll address set-up to ale 17 t clcl ? 25 ns t llax address hold after ale 17 t clcl ? 25 ns t lliv ale low to valid instruction in 80 4 t clcl ? 87 ns t llpl ale to psen 22 t clcl ? 20 ns t plph psen pulse width 95 3 t clcl ? 30 ns t pliv psen to valid instruction in 60 3 t clcl ? 65 ns t pxix input instruction hold after psen 00 ns t pxiz (2) input instruction float after psen 32 t clcl ? 10 ns t pxav (2) address valid after psen 37 t clcl ? 5 ns t aviv address to valid instruction in 148 5 t clcl ? 60 ns t azpl address float to psen ?10 ?10 ns table 119. external clock drive (with the 5 v mcu module) symbol parameter (1) 40 mhz oscillator variable oscillator 1/t clcl = 24 to 40 mhz unit min. max. min. max. t rlrh oscillator period 25 41.7 ns t wlwh high time 10 t clcl ? t clcx ns t llax2 low time 10 t clcl ? t clcx ns t rhdx rise time 10 ns t rhdx fall time 10 ns
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 162/181 1. conditions (in addition to those in table 111 , v cc = 3.0 to 3.6 v): v ss = 0 v; c l for port 0, ale and psen output is 100 pf, for 5 v devices, and 50 pf for 3 v devices; c l for other outputs is 80 pf, for 5 v devices, and 50 pf for 3 v devices) figure 70. external data memory read cycle figure 71. external data memory write cycle table 120. external clock drive (with the 3 v mcu module) symbol parameter (1) 24 mhz oscillator variable oscillator 1/t clcl = 8 to 24 mhz unit min. max. min. max. t rlrh oscillator period 41.7 125 ns t wlwh high time 12 t clcl ? t clcx ns t llax2 low time 12 t clcl ? t clcx ns t rhdx rise time 12 ns t rhdx fall time 12 ns port 2 port 0 ale rd psen p2.0 to p2.3 or a8-a11 from dph a8-a11 from pch tavdv trldv tllwl trlrh tavll tlldv tlhll trlaz data in a0-a7 from pcl instr in a0-a7 from ri or dpl tllax2 tavwl trhdz twhlh ai07088 trhdx port 2 port 0 ale wr psen p2.0 to p2.3 or a8-a11 from dph a8-a11 from pch tqvwx tllwl twlwh tavll tlhll tqvwh data out a0-a7 from pcl instr in a0-a7 from ri or dpl tllax tavwl twhqx twhlh ai07089
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 163/181 1. conditions (in addition to those in table 110 , v cc = 4.5 to 5.5 v): v ss = 0 v; c l for port 0, ale and psen output is 100 pf; c l for other outputs is 80 pf table 121. external data memory ac characteristics (with the 5 v mcu module) symbol parameter (1) 40 mhz oscillator variable oscillator 1/t clcl = 24 to 40 mhz unit min. max. min. max. t rlrh rd pulse width 120 6 t clcl ? 30 ns t wlwh wr pulse width 120 6 t clcl ? 30 ns t llax2 address hold after ale 10 t clcl ? 15 ns t rhdx rd to valid data in 75 5 t clcl ? 50 ns t rhdx data hold after rd 00 ns t rhdz data float after rd 38 2 t clcl ? 12 ns t lldv ale to valid data in 150 8 t clcl ? 50 ns t avdv address to valid data in 150 9 t clcl ? 75 ns t llwl ale to wr or rd 60 90 3 t clcl ? 15 t clcl + 15 ns t avwl address valid to wr or rd 70 4 t clcl ? 30 ns t whlh wr or rd high to ale high 10 40 t clcl ? 15 t clcl + 15 ns t qvwx data valid to wr transition 5 t clcl ? 20 ns t qvwh data set-up before wr 125 7 t clcl ? 50 ns t whqx data hold after wr 5t clcl ? 20 ns t rlaz address float after rd 00ns
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 164/181 1. conditions (in addition to those in table 111 , v cc = 3.0 to 3.6 v): v ss = 0 v; c l for port 0, ale and psen output is 100 pf, for 5 v devices, and 50 pf for 3 v devices; c l for other outputs is 80 pf, for 5 v devices, and 50 pf for 3 v devices) table 122. external data memory ac characteristics (with the 3 v mcu module) symbol parameter (1) 24 mhz oscillator variable oscillator 1/t clcl = 8 to 24 mhz unit min. max. min. max. t rlrh rd pulse width 180 6 t clcl ? 70 ns t wlwh wr pulse width 180 6 t clcl ? 70 ns t llax2 address hold after ale 56 2 t clcl ? 27 ns t rhdx rd to valid data in 118 5 t clcl ? 90 ns t rhdx data hold after rd 00 ns t rhdz data float after rd 63 2 t clcl ? 20 ns t lldv ale to valid data in 200 8 t clcl ? 133 ns t avdv address to valid data in 220 9 t clcl ? 155 ns t llwl ale to wr or rd 75 175 3 t clcl ? 50 t clcl + 50 ns t avwl address valid to wr or rd 67 4 t clcl ? 97 ns t whlh wr or rd high to ale high 17 67 t clcl ? 25 t clcl + 25 ns t qvwx data valid to wr transition 5 t clcl ? 37 ns t qvwh data set-up before wr 170 7 t clcl ? 122 ns t whqx data hold after wr 15 t clcl ? 27 ns t rlaz address float after rd 00ns table 123. a/d analog specification symbol parameter test condition min. typ. max. unit av ref analog power supply input voltage range v ss v cc v v an analog input voltage range v ss ? 0.3 av ref + 0.3 v i avdd current following between v cc and v ss 200 a ca in overall accuracy 2 l.s.b. n nle non-linearity error 2 l.s.b. n dnle differential non-linearity error 2 l.s.b. n zoe zero-offset error 2 l.s.b. n fse full scale error 2 l.s.b. n ge gain error 2 l.s.b. t conv conversion time at 8 mhz clock 20 s
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 165/181 figure 72. input to output disable / enable 1. fast slew rate output available on pa3-pa0, pb3- pb0, and pd2-pd1. decrement times by given amount 2. t pd for mcu address and control signals refers to delay from pins on port 0, port 2, rd wr , psen and ale to cpld combinatorial output (80-pin package only) 1. fast slew rate output available on pa3-pa0, pb3- pb0, and pd2-pd1. decrement times by given amount 2. t pd for mcu address and control signals refers to delay from pins on port 0, port 2, rd wr , psen and ale to cpld combinatorial output (80-pin package only) table 124. cpld combinatorial timing (5 v devices) symbol parameter conditions min. max. pt aloc turbo off slew rate (1) unit t pd (2) cpld input pin/feedback to cpld combinatorial output 20 + 2 + 10 ? 2 ns t ea cpld input to cpld output enable 21 + 10 ? 2 ns t er cpld input to cpld output disable 21 + 10 ? 2 ns t arp cpld register clear or preset delay 21 + 10 ? 2 ns t arpw cpld register clear or preset pulse width 10 + 10 ns t ard cpld array delay any macrocell 11 + 2 ns table 125. cpld combinatorial timing (3 v devices) symbol parameter conditions min. max. pt aloc turbo off slew rate (1) unit t pd (2) cpld input pin/feedback to cpld combinatorial output 40 + 4 + 20 ? 6 ns t ea cpld input to cpld output enable 43 + 20 ? 6 ns t er cpld input to cpld output disable 43 + 20 ? 6 ns t arp cpld register clear or preset delay 40 + 20 ? 6 ns t arpw cpld register clear or preset pulse width 25 + 20 ns t ard cpld array delay any macrocell 25 + 4 ns ter tea input input to output enable/disable ai02863
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 166/181 figure 73. synchronous clock mode timing ? pld 1. fast slew rate output available on pa3-pa0, pb3- pb0, and pd2-pd1. decrement times by given amount. 2. clkin (pd1) t clcl = t ch + t cl . table 126. cpld macrocell synchronous clock mode timing (5 v devices) symbol parameter conditions min. max. pt aloc turbo off slew rate (1) unit f max maximum frequency external feedback 1/(t s +t co )40.0 mhz maximum frequency internal feedback (f cnt ) 1/(t s +t co ?10) 66.6 mhz maximum frequency pipelined data 1/(t ch +t cl )83.3 mhz t s input setup time 12 + 2 + 10 ns t h input hold time 0 ns t ch clock high time clock input 6 ns t cl clock low time clock input 6 ns t co clock to output delay clock input 13 ? 2 ns t ard cpld array delay any macrocell 11 + 2 ns t min minimum clock period (2) t ch +t cl 12 ns t ch t cl t co t h t s clkin input registered output ai02860
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 167/181 1. fast slew rate output available on pa3-pa0, pb3- pb0, and pd2-pd1. decrement times by given amount. 2. clkin (pd1) t clcl = t ch + t cl . figure 74. asynchronous reset / preset figure 75. asynchronous clock mode timing (product term clock) table 127. cpld macrocell synchronous clock mode timing (3 v devices) symbol parameter conditions min. max. pt aloc turbo off slew rate (1) unit f max maximum frequency external feedback 1/(t s +t co )22.2 mhz maximum frequency internal feedback (f cnt ) 1/(t s +t co ?10) 28.5 mhz maximum frequency pipelined data 1/(t ch +t cl )40.0 mhz t s input setup time 20 + 4 + 20 ns t h input hold time 0 ns t ch clock high time clock input 15 ns t cl clock low time clock input 10 ns t co clock to output delay clock input 25 ? 6 ns t ard cpld array delay any macrocell 25 + 4 ns t min minimum clock period (2) t ch +t cl 25 ns tarp register output tarpw reset/preset input ai02864 tcha tcla tcoa tha tsa clock input registered output ai02859
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 168/181 table 128. cpld macrocell asynchronous clock mode timing (5 v devices) symbol parameter conditions min max pt aloc turbo off slew rate unit f maxa maximum frequency external feedback 1/(t sa +t coa )38.4 mhz maximum frequency internal feedback (f cnta ) 1/(t sa +t coa ? 10) 62.5 mhz maximum frequency pipelined data 1/(t cha +t cla )71.4 mhz t sa input setup time 7 + 2 + 10 ns t ha input hold time 8 ns t cha clock input high time 9 + 10 ns t cla clock input low time 9 + 10 ns t coa clock to output delay 21 + 10 ? 2 ns t arda cpld array delay any macrocell 11 + 2 ns t mina minimum clock period 1/f cnta 16 ns table 129. cpld macrocell asynchronous clock mode timing (3 v devices) symbol parameter conditions min. max. pt aloc turbo off slew rate unit f maxa maximum frequency external feedback 1/(t sa +t coa )21.7 mhz maximum frequency internal feedback (f cnta ) 1/(t sa +t coa ? 10) 27.8 mhz maximum frequency pipelined data 1/(t cha +t cla )33.3 mhz t sa input setup time 10 + 4 + 20 ns t ha input hold time 12 ns t cha clock input high time 17 + 20 ns t cla clock input low time 13 + 20 ns t coa clock to output delay 36 + 20 ? 6 ns t ard cpld array delay any macrocell 25 + 4 ns t mina minimum clock period 1/f cnta 36 ns
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 169/181 figure 76. input macrocell timing (product term clock) 1. inputs from port a, b, and c relative to register/ la tch clock from the pld. ale/as latch timings refer to t avlx and t lxax . 1. inputs from port a, b, and c relative to register/lat ch clock from the pld. ale latch timings refer to t avlx and t lxax . table 130. input macrocell timing (5 v devices) symbol parameter conditions min. max. pt aloc turbo off unit t is input setup time (note 1) 0 ns t ih input hold time (note 1) 15 + 10 ns t inh nib input high time (note 1) 9 ns t inl nib input low time (note 1) 9 ns t ino nib input to combinatorial delay (note 1) 34 + 2 + 10 ns table 131. input macrocell timing (3 v devices) symbol parameter conditions min. max. pt aloc turbo off unit t is input setup time (note 1) 0 ns t ih input hold time (note 1) 25 + 20 ns t inh nib input high time (note 1) 12 ns t inl nib input low time (note 1) 12 ns t ino nib input to combinatorial delay (note 1) 46 + 4 + 20 ns t inh t inl t ino t ih t is pt clock input output ai03101
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 170/181 1. programmed to all zero before erase. 2. the polling status, dq7, is valid t q7vqv time units before the data byte , dq0-dq7, is valid for reading. 1. programmed to all zero before erase. 2. the polling status, dq7, is valid t q7vqv time units before the data byte , dq0-dq7, is valid for reading. table 132. program, write and erase times (5 v devices) symbol parameter min. typ. max. unit flash program 8.5 s flash bulk erase (1) (pre-programmed) 3 30 s flash bulk erase (not pre-programmed) 5 s t whqv3 sector erase (pre-programmed) 1 30 s t whqv2 sector erase (not pre-programmed) 2.2 s t whqv1 byte program 14 150 s program / erase cycles (per sector) 100,000 cycles t whwlo sector erase time-out 100 s t q7vqv dq7 valid to output (dq7-dq0) valid (data polling) (2) 30 ns table 133. program, write and erase times (3 v devices) symbol parameter min. typ. max. unit flash program 8.5 s flash bulk erase (1) (pre-programmed) 3 30 s flash bulk erase (not pre-programmed) 5 s t whqv3 sector erase (pre-programmed) 1 30 s t whqv2 sector erase (not pre-programmed) 2.2 s t whqv1 byte program 14 150 s program / erase cycles (per sector) 100,000 cycles t whwlo sector erase time-out 100 s t q7vqv dq7 valid to output (dq7-dq0) valid (data polling) (2) 30 ns
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 171/181 figure 77. peripheral i/o read timing 1. any input used to select port a data peripheral mode. 2. data is already stable on port a. 1. any input used to select port a data peripheral mode. 2. data is already stable on port a. table 134. port a peripheral data mode read timing (5 v devices) symbol parameter condition s min. max. turbo off unit t avqv?pa address valid to data valid (note 1) 37 + 10 ns t slqv?pa csi valid to data valid 27 + 10 ns t rlqv?pa rd to data valid (note 2) 32 ns t dvqv?pa data in to data out valid 22 ns t rhqz?pa rd to data high-z 23 ns table 135. port a peripheral data mode read timing (3 v devices) symbol parameter conditions min. max. turbo off unit t avqv?pa address valid to data valid (note 1) 50 + 20 ns t slqv?pa csi valid to data valid 37 + 20 ns t rlqv?pa rd to data valid (note 2) 45 ns t dvqv?pa data in to data out valid 38 ns t rhqz?pa rd to data high-z 36 ns t rlqv ( pa) t dvqv ( pa) t rhqz ( pa) t slqv ( pa) t avqv ( pa) address data valid ale a /d bus rd data on port a csi ai06610
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 172/181 figure 78. peripheral i/o write timing 1. data stable on port 0 pins to data on port a. 1. data stable on port 0 pins to data on port a. figure 79. reset (reset ) timing table 136. port a peripheral data mode write timing (5 v devices) symbol parameter conditions min. max. unit t wlqv?pa wr to data propagation delay 25 ns t dvqv?pa data to port a data propagation delay (note 1) 22 ns t whqz?pa wr invalid to port a tri-state 20 ns table 137. port a peripheral data mode write timing (3 v devices) symbol parameter conditions min. max. unit t wlqv?pa wr to data propagation delay 42 ns t dvqv?pa data to port a data propagation delay (note 1) 38 ns t whqz?pa wr invalid to port a tri-state 33 ns tdvqv (pa) twlqv (pa) twhqz (pa) address data out a /d bus wr port a data out ale ai06611 t nlnh-po t opr ai02866b reset t nlnh t nlnh-a t opr v cc v cc (min) power-on reset warm reset
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 173/181 1. reset (reset ) does not reset flash memory program or erase cycles. 2. warm reset aborts flash memory program or erase cycles, and puts the device in read mode. 1. reset (reset ) does not reset flash memory program or erase cycles. 2. warm reset aborts flash memory program or erase cycles, and puts the device in read mode. figure 80. isc timing table 138. reset (reset ) timing (5 v devices) symbol parameter conditions min. max. unit t nlnh reset active low time (1) 150 ns t nlnh?po power-on reset active low time 1 ms t nlnh?a warm reset (2) 25 s t opr reset high to operational device 120 ns table 139. reset (reset ) timing (3 v devices) symbol parameter conditions min. max. unit t nlnh reset active low time (1) 300 ns t nlnh?po power-on reset active low time 1 ms t nlnh?a warm reset (2) 25 s t opr reset high to operational device 300 ns iscch tck tdi/tms isc outputs/tdo isc outputs/tdo t isccl t iscph t iscpsu t iscpvz t iscpzv t iscpco t ai02865
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 174/181 1. for non-pld programming, erase or in isc by-pass mode. 2. for program or erase pld only. 1. for non-pld programming, erase or in isc by-pass mode. 2. for program or erase pld only. figure 81. mcu module ac measurement i/o waveform 1. ac inputs during testing are driven at v cc ?0.5 v for a logic '1,' and 0.45 v for a logic '0.' 2. timing measurements are made at v ih (min) for a logic '1,' and v il (max) for a logic '0'. table 140. isc timing (5 v devices) symbol parameter conditions min. max. unit t isccf clock (tck, pc1) frequency (except for pld) (note 1) 20 mhz t iscch clock (tck, pc1) high ti me (except for pld) (note 1) 23 ns t isccl clock (tck, pc1) low time (except for pld) (note 1) 23 ns t isccfp clock (tck, pc1) frequency (pld only) (note 2) 2 mhz t iscchp clock (tck, pc1) high time (pld only) (note 2) 240 ns t iscclp clock (tck, pc1) low time (pld only) (note 2) 240 ns t iscpsu isc port set-up time 7 ns t iscph isc port hold-up time 5 ns t iscpco isc port clock to output 21 ns t iscpzv isc port high-impedance to valid output 21 ns t iscpvz isc port valid output to high-impedance 21 ns table 141. isc timing (3 v devices) symbol parameter conditions min. max. unit t isccf clock (tck, pc1) frequency (except for pld) (note 1) 12 mhz t iscch clock (tck, pc1) high time (except for pld) (note 1) 40 ns t isccl clock (tck, pc1) low time (except for pld) (note 1) 40 ns t isccfp clock (tck, pc1) frequency (pld only) (note 2) 2 mhz t iscchp clock (tck, pc1) high time (pld only) (note 2) 240 ns t iscclp clock (tck, pc1) low time (pld only) (note 2) 240 ns t iscpsu isc port set-up time 12 ns t iscph isc port hold-up time 5 ns t iscpco isc port clock to output 30 ns t iscpzv isc port high-impedance to valid output 30 ns t iscpvz isc port valid output to high-impedance 30 ns ai06650 v cc ? 0.5v 0.45v test points 0.2 v cc ? 0.1v 0.2 v cc + 0.9v
upsd3212a, upsd3212c, upsd 3212cv dc and ac parameters 175/181 figure 82. psd module ac float i/o waveform 1. for timing purposes, a port pi n is considered to be no longer floating when a 100mv change from load voltage occurs, and begins to float when a 100mv change from the loaded v oh or v ol level occurs 2. i ol and i oh 20ma figure 83. external clock cycle figure 84. recommended oscillator circuits 1. c1, c2 = 30 pf 10 pf for crystals 2. for ceramic resonators, c ontact resonator manufacturer 3. oscillation circuit is designed to be used either with a ceramic resonator or crystal oscillator. since each crystal and ceramic resonator 4. have their own characterist ics, the user should consult the crysta l manufacturer for appropriate values of external components. figure 85. psd module ac measurement i/o waveform ai06651 test reference points v ol + 0.1v v oh ? 0.1v v load ? 0.1v v load + 0.1v 0.2 v cc ? 0.1v 3.0v 0v test point 1.5v ai03103b
dc and ac parameters upsd3212a, upsd3212c, upsd3212cv 176/181 figure 86. psd module ac measurement load circuit 1. sampled only, not 100% tested. 2. typical values are for t a = 25c and nominal supply voltages. table 142. capacitance symbol parameter test conditions (1) typ. (2) max. unit c in input capacitance (for input pins) v in = 0 v 4 6 pf c out output capacitance (for input/output pins) v out = 0 v 8 12 pf device under test 2.01 v 195 c l = 30 pf (including scope and jig capacitance) ai03104b
upsd3212a, upsd3212c, upsd3212cv package mechanical information 177/181 32 package mechanical information figure 87. lqfp52 ? 52-lead plastic thin, quad, flat package outline 1. drawing is not to scale. table 143. lqfp52 ? 52-lead plastic thin, quad, flat package mechanical data symbol millimeters inches (1) 1. values in inches are converted from mm and rounded to 4 decimal digits. typ min max typ min max a 1.60 0.063 a1 0.05 0.15 0.002 0.0059 a2 1.35 1.45 0.0531 0.0571 b 0.22 0.38 0.0087 0.015 c 0.09 0.2 0.0035 0.0079 d 12 0.4724 d1 10 0.3937 d2 7.8 0.3071 e 12 0.4724 e1 10 0.3937 e2 7.8 0.3071 e 0.65 0.0256 l 0.45 0.75 0.0177 0.0295 l1 1 0.0394 k 07 07 ddd 0.100 0.0039 seating plane a a2 a1 d d1 d2 e2 e1 e 39 27 26 40 52 1 13 14 pin 1 identification e b l1 l k 0.25 mm .010 inch gage plane c ddd c dc_me
package mechanical information upsd3212a, upsd3212c, upsd3212cv 178/181 figure 88. lqfp80 ? 80-lead plastic thin, quad, flat package outline 1. drawing is not to scale. table 144. lqfp80 ? 80-lead plastic thin, quad, flat package mechanical data symbol millimeters inches (1) 1. values in inches are converted from mm and rounded to 4 decimal digits. typ min max typ min max a 1.600 0.0630 a1 0.050 0.150 0.0020 0.0059 a2 1.400 1.350 1.450 0.0551 0.0531 0.0571 b 0.220 0.170 0.270 0.0087 0.0067 0.0106 c 0.090 0.200 0.0035 0.0079 d 14.000 0.5512 d1 12.000 0.4724 d3 9.500 0.3740 e 14.000 0.5512 e1 12.000 0.4724 e3 9.500 0.3740 e 0.500 0.0197 l 0.600 0.450 0.750 0.0236 0.0177 0.0295 l1 1.000 0.0394 k 0 7 0 7 ccc 0.080 0.0031 9x_me e1 ccc b e a2 a l a1 k d1 d e c d3 e3 l1 1 20 21 40 41 60 61 80 pin 1 identification
upsd3212a, upsd3212c, up sd3212cv part numbering 179/181 33 part numbering table 145. ordering information scheme for other options, or for more information on any aspect of this device, please contact the st sales office nearest you. example: upsd 3 2 1 4 b v ? 24 u 6 t device type upsd = microcontroller psd family 3 = 8032 core pld size 2 = 16 macrocells sram size 1 = 2 kbytes main flash memory size 2 = 64 kbytes 3 = 128 kbytes 4 = 256 kbytes ip mix a = usb, i 2 c, pwm, ddc, adc, (2) uarts, supervisor (reset out, reset in, lvd, wd) b = i 2 c, pwm, ddc, adc, (2) uarts supervisor (reset out, reset in, lvd, wd) operating voltage blank = v cc = 4.5 to 5.5 v v = v cc = 3.0 to 3.6 v speed ?24 = 24 mhz ?40 = 40 mhz package t = 52-pin lqfp u = 80-pin lqfp temperature range 1 = 0 to 70c 6 = ?40 to 85c shipping options f = ecopack ? package, tape & reel packing
revision history upsd3212a, upsd3212c, upsd3212cv 180/181 34 revision history table 146. document revision history date revision changes 18-dec-2002 1.0 first issue 04-mar-03 1.1 updates: port information (table 30 ); interface information (figure 30 , ta bl e 44 ); remove programming guide; psd module information (table 82 ); pld information (figure 55 ); electrical characteristics (table 114 , 115 , 131 , 132 ) 02-sep-03 1.2 update references for product catalog 03-feb-04 2.0 reformatted; correct package dimensions (table 145 ) 02-july-04 3.0 reformatted; add emc characteristics information (table 106 , 107 , 108 ) 04-nov-04 4.0 updates per requested data brief changes (figure 3 , 4 ; table 1 , 2 , 113 ) 03-dec-04 5.0 add usb feature to document (figure 2 , 3 , 4 , 15 , 16 , 18 , 20 , 40 , 41 , 42 , 43 , 44 , 45 ; table 1 , 2 , 15 , 16 , 18 , 19 , 21 , 23 , 24 , 25 , 60 , 61 , 62 , 63 , 64 , 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 146 ) 21-jan-2009 6.0 removed battery backup feature and related sram standby mode information. added ecopack information and updated section 32: package mechanical information on page 177 .
upsd3212a, upsd3212c, upsd3212cv 181/181 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by an authorized st representative, st products are not recommended, authorized or warranted for use in milita ry, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2009 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of UPSD3212A-40U6T

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X